nested repeater

M

mark

(not sure if this is the correct group)

My problem is I need to have a "nested" repeater. I have an array which I
load into a hashtable - that part works great. I can setup the second
repeater to work just fine, as long as it's not nested within the first
repeater. If it is nested within the first repeater, I don't get any data.
If I put the second repeater as a separate repeater, not nested, it works
fine.

Here's my actual code, showing data pulled from the array within a loop:

Dim arrRepeater As New ArrayList()
'Repeat this part for each row
x = 0
Do Until x = db_fieldnamemax
Dim htRepeater As New Hashtable()
htRepeater.Add("ColName1", db_fieldname(x, 1))
htRepeater.Add("ColName2", db_fieldname(x, 2))
arrRepeater.Add(htRepeater)
x += 1
Loop
Repeater1.DataSource = arrRepeater
Repeater1.DataBind()


Dim arrRepeater2 As New ArrayList()
'Repeat this part for each row
x = 0
Do Until x = db_fieldproductmax
Dim htRepeater As New Hashtable()
htRepeater.Add("ColProduct1", db_fieldproduct(x, 1))
htRepeater.Add("ColProduct2", db_fieldproduct(x, 2))
arrRepeater.Add(htRepeater)
x += 1
Loop
Repeater2.DataSource = arrRepeater2
Repeater2.DataBind()

Would someone please point me in the right direction on how to use a
nested repeater??

Here is my frontside code (where I think the problem is):

<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
First item: <%#Container.DataItem("ColName1")%>
Second item: <%#Container.DataItem("ColName2")%>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
*** Nested item 1: <%#Container.DataItem("ColProduct1")%>
*** Nested item 2: <%#Container.DataItem("ColProduct2")%>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>


Also, the "Repeater2" shows undefined (in the code behind), unless we add
the following
statement in the code behind:

Partial Class MainPage
Inherits System.Web.UI.Page
Dim Repeater2 As New System.Web.UI.WebControls.Repeater()

-Mark
 
G

Guest

you have to put the binding inside the first repeater's data bound event for
the second repeater
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top