开发者

Is it possible to nest GridViews in asp.net web forms?

开发者 https://www.devze.com 2023-03-08 15:41 出处:网络
I am wondering if it is possible to nest GridView\'s like this? <asp:Panel ID=\"Panel1\" runat=\"server\">

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:

  1. Nested GridView ( Simple )
  2. Nested GridView ( With paging for child )
0

精彩评论

暂无评论...
验证码 换一张
取 消