我有这段代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="something">
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" Style="display: none" >
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" ShowHeader="False">
<Columns>
<asp:BoundField DataField="NAME"></asp:BoundField>
other asp-BoundFields...
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
asp-BoundFields...
</Columns>
</asp:GridView>
CS:在函数void Test()中我想从gridview2的每一行获取值。我尝试使用findcontrol方法,但我认为找不到BoundField。我怎么能这样做?
答案 0 :(得分:0)
在类似论坛上找到解决方案。
GridView Gridview2 = (GridView)GridView1.Rows[1].FindControl("GridView2");