I have a nested repeater control with multiple views. Here the parent repeater is bound to a datatable. When we click on the div in parent repeater, child repeaters will be displayed in a dropdown box. But I'm getting same instance of child repeaters in all views of parent repeater. Please help me to resolve the issue.
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound"> <ItemTemplate> <div class="row row-border pb-1 pt-1 border-bottom border-dark dropdown-toggle" data-toggle="dropdown"> <div class="col-md-2"> <asp:Label ID="LabelDate" runat="server" Text='<%# Eval("id") %>'></asp:Label> </div> <div class="col-md-2"> <asp:Label ID="Label1" runat="server" Text="Test 1"></asp:Label> </div> <div class="col-md-2"> <asp:Label ID="Label2" runat="server" Text="Test 2"></asp:Label> </div> <div class="col-md-2"> <asp:Label ID="Label3" runat="server" Text="Test 3"></asp:Label> </div> <div class="col-md-2"> <asp:Label ID="Label4" runat="server" Text="Test 4"></asp:Label> </div> </div> <div class="dropdown-menu dropdown-menu-right"> <div class="row"> <div class="col-md-12"> Header </div> <div class="col-md-6"> <asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <div class="row"> <div class="col-md-12"> <%# Container.DataItem?.ToString() ?? string.Empty%> </div> </div> </ItemTemplate> </asp:Repeater> </div> <div class="col-md-6"> <asp:Repeater ID="Repeater3" runat="server"> <ItemTemplate> <div class="row"> <div class="col-md-12"> <%# Container.DataItem?.ToString() ?? string.Empty%> </div> </div> </ItemTemplate> </asp:Repeater> </div> </div> </div> </ItemTemplate> </asp:Repeater>
Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { ... var Temp1= new List<string>(); var Temp2= new List<string>(); ... Repeater Rptr2 = (e.Item.FindControl("Repeater2") as Repeater); Repeater Rptr3 = (e.Item.FindControl("Repeater3") as Repeater); Rptr2.DataSource = Temp1; Rptr3.DataSource = Temp2; Rptr2.DataBind(); Rptr3.DataBind(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)