Reputation: 159
I've got a Repeater control which is bound to a DataTable. When I update the data table the rendered repeater control is not updated. What can I use so an update to the data table causes the repeater control to be updated?
Here's the code for the repeater
<asp:Repeater ID="Repeater3" runat="server" >
<HeaderTemplate><ol id="selectable"></HeaderTemplate>
<ItemTemplate>
<li style= "<%# Eval(@"STYLE").ToString() %>" > <%# Eval(@"ITEM").ToString() %> </li>
</ItemTemplate>
<FooterTemplate></ol></FooterTemplate>
</asp:Repeater>
I am updating the "STYLE" column in the data table in the code behind.
Thanks
Upvotes: 1
Views: 359
Reputation: 22436
After you update the DataTable, you need to DataBind the repeater again after the data have been changed in order to show the updated content:
// Change the data
Repeater3.DataSource = newDataTable;
Repeater3.DataBind();
In contrast to WinForms, there is no permanent connection between the data source and the bound control in ASP.NET. That's why you need to explicitly renew the data binding once changes have occurred.
Upvotes: 1