Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > nested repeater

Reply
Thread Tools

nested repeater

 
 
mark
Guest
Posts: n/a
 
      10-13-2005
(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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q3VydF9DIFtNVlBd?=
Guest
Posts: n/a
 
      10-13-2005
you have to put the binding inside the first repeater's data bound event for
the second repeater

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



"mark" wrote:

> (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
>
>
>

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-13-2005
Curt's suggestion is the best. If you need an example, check out:
http://openmymind.net/index.aspx?documentId=8#7 (it also mentions an
alternative, doing it inline).

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeater inside a repeater problem. uncensored ASP .Net 0 10-25-2006 06:10 PM
Repeater inside a Repeater Microsoft ASP .Net Web Controls 0 08-21-2006 09:13 AM
Repeater inside a repeater....how? voidfill3d@yahoo.com ASP .Net 1 08-10-2005 01:58 PM
Repeater Using Javascript Referencing a Column in the Repeater rwoo_98@yahoo.com ASP .Net 0 02-26-2005 05:02 PM
Repeater control with nested repeater chris.reed@digus.com ASP .Net 0 02-11-2005 05:10 PM



Advertisments