是否可以在 ASP.NET Web 表单中嵌套 GridView?
我想知道是否可以像这样嵌套 GridView?
<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 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 any advice is much appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上只需要使用外部的 OnRowDataBound 来绑定内部,否则这是完全可能的。
虽然我不喜欢这样做,但众所周知我自己也这样做。相反,我建议使用一组嵌套的重复器,因为标记通常更简单,但需要更多的 HTML。
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.