Helpful Information
 
 
Category: ASP.NET
Nested Repeaters

Greetings!

I don't know why I'm having such a hard time with this, but here is what I'm trying to do:

The data set returns a table essentially like this:

Sub Type | Name | Phone #

so...multiple records with a data grid come out like this:

Bollards | Company A | 555-5555
Bollards | Company B | 555-5678
Bollards | Company C | 555-9999
Gabions | Company D | 555-9876
Gabions | Company E | 555-1234

I'm trying to implement nested Repeaters so that the output looks something like this:

Bollards:
Company A | 555-5555
Company B | 555-5678
Company C | 555-9999
Gabions:
Company D | 555-9876
Company E | 555-1234

For some reason, my nested repeater is not being recognized as such. When I try to bind data to it earlier in my code, I get an error saying the repeater is undifined, although it rests just below the <ItemTemplate> tag of the first repeater. I tried specifying the DataSource in the <asp:repeater> tag, but that gives me a parse error.

I'm not sure if my structure is right either, but here is that section of code (note this doesn't work currently):


<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="1">
</HeaderTemplate>
<ItemTemplate>
<asp:Repeater ID="Repeater2" runat="server" DataSource='values'>
<ItemTemplate>
<tr>
<td width="20">&nbsp;</td>
<td><%#DataBinder.Eval(Container.DataItem, "SubType")%></b></i></td>
<td width="120"><%#DataBinder.Eval(Container.DataItem, "Company Name")%></td>
<td width="110"><%#DataBinder.Eval(Container.DataItem, "Contact")%></td>
<td width="110"><%#DataBinder.Eval(Container.DataItem, "Phone")%></td>
<td width="30"><%#DataBinder.Eval(Container.DataItem, "Extension")%></td>
<td width="110"><%#DataBinder.Eval(Container.DataItem, "Fax")%></td>
<td width="110"><%#DataBinder.Eval(Container.DataItem, "Mobil")%></td>
<td width="120"><%#DataBinder.Eval(Container.DataItem, "Extra")%></td>
<td width="120">&nbsp;</td><p>
</table>
</tr>
</ItemTemplate>
</asp:Repeater>
</itemtemplate>
</asp:Repeater>

Any advice is SINCERELY appreciated! I'm stumped.

you need to bind the child repeater to the parent repeater. here is an article that describes how to do this http://support.microsoft.com/default.aspx?scid=kb;EN-US;326338

Thanks Miranda! I'm off to a good start....

Here's what I've got so far, and it seems like none of the little variations I've been trying work. If anybody can point me in the right direction, I'd be much obliged. Here's the important piece of the code:


cmdMbrs = New OleDbCommand( _
"SELECT * " & _
"FROM tblSubType " & _
"WHERE (((tblSubType.SubType)=" & strWhere & "))" & _
"ORDER BY tblSubType.SubType;", conClsf)

cmdMbrs2 = New OleDbCommand( _
"SELECT * " & _
"FROM tblSubContractors " & _
"WHERE (((tblSubContractors.SubType)=" & strWhere & "))" & _
"ORDER BY tblSubContractors.SubType;", conClsf)


Dim DA as OleDbDataAdapter = New OleDbDataAdapter
Dim DA2 as OleDbDataAdapter = New OleDbDataAdapter

DA.SelectCommand = cmdMbrs

Dim ds As DataSet = New DataSet
Dim tblType as DataTable
Dim tblContractors as DataTable

ds.Tables.Add("tblType")
ds.Tables.Add("tblContractors")

rdrMbrs = cmdMbrs.ExecuteReader

DA.Fill("tblType", rdrMbrs)

DA2.SelectCommand = cmdMbrs2

conClsf.close

conClsf.Open

rdrMbrs2 = cmdMbrs2.ExecuteReader

DA2.Fill("tblContractors", rdrMbrs2)

Dim parentCol As DataColumn
Dim childCol As DataColumn

parentCol = ds.Tables("tblSubType").Columns("SubType")
childCol = ds.Tables("tblSubContractors").Columns("SubType")


myRel = New System.Data.DataRelation("Subs", parentCol, childCol)
ds.Relations.Add(myRel)

Repeater1.DataSource = ds.Tables("tblSubType")
Repeater1.DataBind()

cmdMbrs.Dispose
cmdMbrs2.Dispose
conClsf.Close

Please help! Thanks much.

I am also facing same problem. did your problem got solved? if yes please let me know. waiting for your early reply.


-gk:)

Hi,
I would use server side event ItemCreated of the Repeater and in this event handler I would specify the output for each record.










privacy (GDPR)