Nested repeater with 3 levels

Discussion in 'ASP .Net' started by Eirik Eldorsen, Feb 3, 2005.

  1. Im trying to make a nested repeater with 3 levels. I've successfully created
    a nested repeater with 2 levels, but when adding the 3rd level I get an
    InvalidCastException. What am I doing wrong?

    Here is my code:

    <asp:Repeater id="level1Repeater" runat="server">
    <a href="#"><%# DataBinder.Eval(Container.DataItem, "Title") %></a>
    <asp:repeater id="level2Repeater" runat="server" datasource='<%#
    ((DataRowView)Container.DataItem).Row.GetChildRows("L1L2") %>' >
    &nbsp;<a href="#"><%# DataBinder.Eval(Container.DataItem,
    <asp:repeater id="level3Repeater" runat="server"
    datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("L2L3")
    %>' >
    &nbsp;&nbsp;<a href="#"><%#
    DataBinder.Eval(Container.DataItem, "[\"Title\"]")%><br></a>

    Code Behind:

    private void BindWebsites()
    level1Repeater.DataSource = Websites.GetAll();

    public static DataTable GetAll()
    ds.Relations.Add("L1L2", ds.Tables["WebsitesL1"].Columns["ID"],
    ds.Relations.Add("L2L3", ds.Tables["WebsitesL2"].Columns["ID"],

    return ds.Tables["WebsitesL1"];
    Eirik Eldorsen, Feb 3, 2005
    1. Advertisements

  2. Eirik Eldorsen

    Karl Seguin Guest

    Weird, everything looks good...While you shouln't have to, maybe if you move
    the nesting to the OnItemCommand event you'll figure out hte problem:


    MY ASP.Net tutorials

    Karl Seguin, Feb 3, 2005
    1. Advertisements

  3. Thank you!

    I moved the nesting to the OnItemDataBound event, and now everything works

    Eirik Eldorsen, Feb 4, 2005
  4. Eirik Eldorsen

    acanel Guest

    (sorry but my english is so bad)
    hey, you can send me code?

    acanel, Feb 20, 2005
  5. Eirik Eldorsen


    Sep 18, 2011
    Likes Received:
    Hello, I have been looking for a solution only with 2 repeaters. Could you please send me the full code if you still have it?

    Many thanks
    swestwood, Sep 18, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.