I have a page with a simple dropdown and repeater control in page.on submit repeater control is bound to datasource1 which has 3 columns.
Now my requirement is if i select option2 , it should bind to datasource2 which contains 4 columns.
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>
<tr>
<th align="left">Header1</th>
<th align="left">Header3</th>
<th align="left">Header2</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Header1" runat="server" /></td>
<td>
<asp:Label ID="Header3" runat="server" /></td>
<td>
<asp:Label ID="Header2" runat="server" /></td>
</tr>
</ItemTemplate>
Is it possible for the same repeater to dynamically bind to heterogeneous data sources?How can i specify the header template and item templates at run- time? Can this scenario be implemented with just one repeater control and multiple heterogeneous data sources?
You can simply use like this -
Feels below code will help you .
or in other way using 2 different User control.First user control contain repeater1, second contain repeater2.Then dynamic add these repeaters to your page, at code behind
Try settings AutoPostback=true on your dropdownlist. Then, have a "selectedindexchanged" event handler on your codebehind setup to read the value and set the datasource accordingly, something similar to:
If your datasource is always using the same columns for your presentation, then this shouldn't be an issue. If your datasources will vary in the columns of data that they return, then Kashif's comment in your question may help you some. Otherwise, you just need to fill in the logic above to set the Datasource property of your repeater to whatever your datasource is...
Hope this helps
With bootstrap and datatables.net plugins