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