Is it possible to nest GridViews in asp.net web forms?
I am wondering if it is possible to nest GridView's like this?
<asp:Panel ID="Panel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gvNCReports" runat="server" Width="100%" BackColor="White"
AutoGenerateColumns="false" RowStyle-BorderColor="DarkGray"
BorderWidth="1">
<AlternatingRowStyle BackColor="LightGray" />
<Columns>
<asp:BoundField DataField="assessmentName"
HeaderText="Assessment Name"
SortExpression="assessmentName" />
<asp:TemplateField>
<asp:GridView ID="gvNClinks" runat="server" Width="100%"
BackColor="White" AutoGenerateColumns="false"
RowStyle-BorderColor="DarkGray" BorderWidth="1">
<AlternatingRowStyle BackColor="LightGray" />
<Columns> </Columns>
</asp:GridView>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:Panel>
I am new to web form, so an开发者_StackOverflow社区y advice is much appreciated.
Thanks
You really just have to bind the inner using a OnRowDataBound for the outer, and otherwise it's entirely possible.
While I don't like it, I've been known to do it myself. I recommend, instead, doing a set of nested repeaters, as the markup is generally simpler, but requires a tad more HTML on your end.
Check these out:
- Nested GridView ( Simple )
- Nested GridView ( With paging for child )
精彩评论