Nested Repeater

D

DE_Kabal

I relatively new to ASP.Net, coming from a ColdFusion background. I'm trying
to create a report that does the following in a table:

Organization1
url pass failed
url pass failed
url pass failed
Organization2
url pass failed
url pass failed
url pass failed

I tried using 2 SQLDataSources and could only get one organization then all
the other data not sorted. I then tried the MicroSoft example, with some
variation, and that didn't work. The result above comes from a single table.
Here is the code I am using from the MS example:

<asp:Repeater ID="parentRepeater" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="3" cellspacing="0" summary="this table
for layout">
<tr>
<td scope="col">Agency</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<strong><%# DataBinder.Eval(Container.DataItem, "agency")
%></strong>
</td>
<asp:Repeater ID="childRepeater" runat="server"
DataSource='<%#
Container.DataItem.Row.GetChildRows("myrelation") %>'>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "url") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "filespass")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "filesfailed")
%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tr>
</ItemTemplate>
</asp:Repeater>

Codebehind
Dim strConn1 As String =
ConfigurationManager.ConnectionStrings("accmon").ConnectionString
Dim MySQL1 As String = "SELECT DISTINCT agency FROM websites WHERE
webDelete = 0 AND webNew = 0"
Dim MyConn1 As New OleDbConnection(strConn1)
Dim cmd1 As New OleDbDataAdapter(MySQL1, MyConn1)
Dim ds As DataSet = New DataSet()
cmd1.Fill(ds, "websites")

'Create table for child repeater
Dim MySQL2 As String = "SELECT webID, url, files508, pass508,
failed508, verify508 FROM websites " & _
"WHERE webDelete = 0 AND webNew = 0"
Dim cmd2 As New OleDbDataAdapter(MySQL2, MyConn1)
cmd2.Fill(ds, "weburl")
ds.Relations.Add("myrelation", _
ds.Tables("websites").Columns("agency"), _
ds.Tables("weburl").Columns("url"))
parentRepeater.DataSource = ds.Tables("websites")
Page.DataBind()
MyConn1.Close()
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top