First, you probably want to take the <asp:Table ID="table1" runat="server">
and </asp:Tablelines outside the repeater. Then the repeater will produce
just one table with items instead of each item being in a separate table.
Second, e.Item.DataItem is a DataRow itself, it neither has no needs any Row
member.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin http://usableasp.net
<mj.redfox.mj@gmail.comwrote in message
news:1171962804.844536.22990@j27g2000cwj.googlegro ups.com...
Quote:
Hi,
>
I wonder if someone could possibly help with this? I have the
following code, which is a nested repeater in turn nesting a datalist.
This all works fine, together with my page-behind vb code controlling
the relations etc.
>
Now, what I'm wanting to do is to call a subroutine 'subroutine1' when
the repeater is data bound, which I'm wanting to use to change the
background colour of table cell tdCell1 depending on the value of
intValue1 in the repeater's data collection...
>
>
>
<asp:Repeater ID="repeater1" runat="server" DataSource='<
%#Container.DataItem.Row.GetChildRows("intValue1") %>'
OnItemDataBound="subroutine1">
<ItemTemplate>
<asp:Table ID="table1" runat="server">
<asp:TableRow>
<asp:TableCell ID="tdCell1">
<asp:DataList ID="datalist1" runat="server" DataSource='<
%#Container.DataItem.GetChildRows("relation2")%>'>
<ItemTemplate><%#Container.DataItem("intValue2")%> </
ItemTemplate>
</asp:DataList>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:Repeater>
>
>
>
I'm struggling with the syntax of how I'd do this. I think I may be
nearly there with the code below, although not quite (this particular
attempt brings back a "Public member 'Row' on type 'DataRow' not
found" error). I'd be grateful if anyone could help as I can't seem to
find any real examples on the net of what I'm trying to do.
>
>
>
Public Sub subroutine1(ByVal Sender As Object, ByVal e As
RepeaterItemEventArgs)
>
Dim tdCell1 As TableCell = e.Item.FindControl("tdCell1")
Dim intTest As Integer =
e.Item.DataItem.Row.GetChildRows("intValue1")
>
If intTest 5 Then
tdCell1.BackColor = Drawing.Color.GreenYellow
End If
>
End Sub
>
>
>
The frustrating thing is that I could do this in five minutes flat in
normal ASP with a nested recordset, but it seems so much more
difficult to do it in .NET. Thanks so much in advance for any
suggestions!
>