Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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. 


What I have tried:

<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();
       }
Posted
Comments
F-ES Sitecore 17-Jul-20 6:13am    
You get the same ones as you are binding Repeater2 and Repeater3 to the same data as the code in Repeater1_ItemDataBound doesn't vary depending on the parent row.
Reshma Tv 17-Jul-20 7:18am    
Yes.. While debugging, i checked and confirmed that correct values are binding to the child repeaters. But in dropdown (When i click on the div in parent repeater) , the first value bound to the child repeaters are showing in all views of parent repeater.

The below javascript code is used to show the dropdown.


$(document).ready(function () {
$('.dropdown-toggle').dropdown();
});
F-ES Sitecore 17-Jul-20 7:38am    
Use view->source to check the raw html. If the right data is in the source then the issue is with your "dropdown" function\css classes.
Reshma Tv 17-Jul-20 8:08am    
Yes.. The data is taking correctly in the source.
F-ES Sitecore 17-Jul-20 8:28am    
What is the "dropdown()" function then? Where is that from?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900