I've got an asp:DataGrid
which has an asp:Gridview
within it and this has many nested asp:Repeater
's within that and i'm trying to reference the nested repeater from within my OnItemDataBound
function
My code is similar to this
<asp:Datagrid runat="server" id="DataGrid1" OnItemDataBound="ItemDB" AutoGenerateColumns="false" Gridlines="None">
<Columns>
<asp:TemplateColumn HeaderText="">
<ItemTemplate>
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<p>Test</p>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:Datagrid>
bit complicated but that's kinda what i'm working with.
In my ItemDB
command I have this
Sub ItemDB(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
If CType(e.Item.FindControl("GridView1"), GridView).Visible = True Then
CType(e.Item.FindControl("Repeater"), GridView).Visible = True
End If
End If
End Sub
but i get the error
Object reference not set to an instance of an object
and i'm guessing it's because i am referencing a Repeater within a GridView
Any ideas how to reference this properly?
This code may not be the simplest way of doing this but i've taken over someone else's work and need a quick fix before re-coding it all
Thanks in advance