简体   繁体   中英

Nested Repeaters - have 3 repeaters

I understand the OnItemDatabound attribute on the Parent Repeater ... makes sense

Here is my question:

lets say my data is structured as follows:

<List>
Parent Level Movie String
   Next Level : Amenities <List>
       Next level:   Showtimes <List>

So I was creating a List of Movies, within that list of Movies is a List of Amenities, within that list of Amenities is the Showtimes

  Movies is Repeater 1 Amenities is Repeater 2 Child of Repeater 1 Showtimes is Repeater 3 Child of Repeater 2 

So, my question is Movies is in a list, and each of the different Repeater items are in a list, can those lists just be used as the DataSource for each Child Repeater, since the data is already contained.

Yes, they can. It's not even hard. Your markup can just look something like this:

<asp:Repeater runat="server">
    <ItemTemplate>
        <asp:Label runat="server" Text='<%# Eval("Title") %>' />

        <asp:Repeater runat="server" DataSource="Amenities ">
            <ItemTemplate>
                <asp:Label runat="server" Text='<%# Eval("SomeField") %>' />

                <asp:Repeater runat="server" DataSource="Showtimes">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" 
                            Text='<%# Eval("SomeOtherField") %>' />
                    </ItemTemplate>
                </asp:Repeater>
            </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>
</asp:Repeater>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM