nested asp.net repeater with objectdatasource

H

Howard

I need to generated a list from data from 2 database tables.
1st list CATEGORY consists of columns
CATID|CATEGORYNAME|

2nd table ITEM has columns
ID|CATEGORYID|NAME|

<asp:repeater id=parent datasourceid=ds1 runat=server>
<itemtemplate>
<h1><%# Eval("CATEGORYNAME")%></h1><ul>
<asp:repeater id=childdatasourceid=ds2 runat=server>
<itemtemplate>
<li><%# Eval("ID")%>. <%# Eval("NAME")%></li>
</itemteplate>
</asp:repeater></ul>
</itemteplate>
</asp:repeater>

The problem with this is the child repeater doesn't know which instance of
the parent repeater it belongs to.
The output looks like this

Category 1
Item 1 of category 1
Item 2 of category 1
Category 2
Item 1 of category 1
Item 2 of category 1
Category 3
Item 1 of category 1
Item 2 of category 1
....

How do you set up a relationship between the two objectdatasources (CATEGORY
and ITEM)?

The correct html output shoud look like this

Category 1
Item 1 of category 1
Item 2 of category 1
Category 2
Item 1 of category 2
Item 2 of category 2
Category 3
Item 1 of category 3
Item 2 of category 3
....

Thanks,
Howard
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top