1

I have a list of objects that I want to display in a particular way, and am having way more trouble than I was expecting. Essentially I need a setup as follows:

  • Parent Level 2 (header)
  • Child Level 3 items in a table

This repeats until the end of the list that gets pulled on each pageload. I've taken a try at nested repeaters but failed.

<asp:Repeater runat="server" ID="parentMeetingRepeater" >
<ItemTemplate>
    <h5><%# GetParentMeetingName(Eval("Id")) %></h5>
    <hr />

    <asp:Repeater runat="server" ID="childMeetingRepeater" >
        <HeaderTemplate>
            <table style="width: 100%;">
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <a href="/Display.aspx?ccbid=<%# Eval("Id")%>"><%# Eval("Name") %></a>
                </td>
                <td>
                    <%# Eval("Description") %>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
</ItemTemplate>                       

There was an event on the parent repeater to databind the 2nd repeater, but I quickly realized theres no logic to tell it to only display level 3 items with a parent of the level2 id. Any ideas how I might be able to attack this? I'm thinking nested repeaters might be the wrong direction. - Thanks

eKoz
  • 83
  • 7

1 Answers1

0

After getting some advice, I ended up using a listview instead. The correct binding with a list of data objects and the nested repeaters was driving me mental so this is a much cleaner route.

               <asp:ListView ID="uxTaxonomies" runat="server" ItemPlaceholderID="itemPlaceholder">
                    <LayoutTemplate>
                        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <h5><%#((TaxonomyData)Container.DataItem).Name %></h5>
                        <hr/>
                        <asp:ListView ID="uxTaxChildren" runat="server" ItemPlaceholderID="itemPlaceholder" DataSource="<%#((TaxonomyData)Container.DataItem).Taxonomy %>">
                            <LayoutTemplate>
                                <table class="noBorder">
                                    <tbody>
                                        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                                    </tbody>
                                </table>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <tr>
                                    <td><a href="/MeetingDisplay.aspx?ccbid=<%#((TaxonomyData)Container.DataItem).Id %>"><%#((TaxonomyData)Container.DataItem).Name %></a>  </td>
                                    <td><%#((TaxonomyData)Container.DataItem).Description %></td>
                                </tr>
                            </ItemTemplate>
                        </asp:ListView>
                    </ItemTemplate>
                </asp:ListView>
eKoz
  • 83
  • 7