Nested Repeater controls

M

Maziar Aflatoun

Hi,

I found an example on Microsoft on having nest repeater controls. So I
created a 3 tables -> Categories, Users and UserInfo. I like to display all
the Categories and under it display all the Users and for each user display
their address (Testing :) ) stored in UserInfo table. I have managed to get
the Categories and Users working. However, I get the following error message
when display the UserInfo under Users. Does anyone know how I can modify my
code to have two child repeaters under Categories?

<asp:Repeater id="parentRepeater" runat="server">
<itemtemplate>
<b>
<%# DataBinder.Eval(Container.DataItem, "Category") %>
</b>
<br>
<asp:repeater id="childRepeater" runat="server" datasource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>'>
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "[\"FullName\"]")%>
<br>
<asp:repeater id="userinfoRepeater" runat="server" datasource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows("myrelation2") %>'>
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "[\"address\"]")%>
<br>
</itemtemplate>
</asp:repeater>
</itemtemplate>
</asp:repeater>
</itemtemplate>
</asp:Repeater>

My code
adapter.TableMappings.Add("Table", "Categories");
adapter.TableMappings.Add("Table1", "Users");
adapter.TableMappings.Add("Table2", "UserInfo");
DataSet ds = new DataSet();
adapter.Fill(ds);
ds.Relations.Add("myrelation", ds.Tables["Categories"].Columns["id"],
ds.Tables["Users"].Columns["catid"]);
ds.Relations.Add("myrelation2", ds.Tables["Users"].Columns["id"],
ds.Tables["UserInfo"].Columns["userid"]);

It returns the error message
System.InvalidCastException: Specified cast is not valid on like
<asp:repeater id="userinfoRepeater"....

Thank you
Maz
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top