I have the following structure in an aspx page:
<asp:Panel ID="pnlCust" runat="server">
<asp:GridView ID="gvMaster" runat="server"
OnRowCreated="gvMaster_RowCreated">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="pnlMaster" runat="server">
//...
</asp:Panel>
<asp:Panel ID="pnlDetails" runat="server">
<asp:GridView ID="gvDetails" runat="server">
<Columns>
//...
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
The panels are used for the CollapsiblePanelExtender from the Ajax Control Toolkit.
I am trying to use FindControl to find the gvDetails control in code-behind, but my latest attempt has not worked, which is in the gvMaster_RowCreated event:
GridView gv =
e.Row.FindControl("pnlDetails").FindControl("gvDetails") as GridView;
where e is GridViewRowEventArgs
I am basically doing what was on this page, but I am not using a SqlDataSource, however, the person is basically finding the SqlDataSource via the FindControl from the e argument passed in from the RowCreated event. Here is the link: