GridView如何在GridView为空时显示页脚
本文关键字:GridView 显示 | 更新日期: 2023-09-27 18:29:35
我有一个网格视图,在其中添加和更新数据。为了添加数据,我使用了页脚模板。在页面加载时,网格视图数据源是空的,所以它不显示页脚-有标题的属性
ShowHeaderWhenEmpty="True"
但我找不到添加页脚的属性。当网格视图为空时,如何显示页脚?
试试这样的东西:
<asp:GridView ID="gvCustomers" runat="server" Width="550px"
AutoGenerateColumns="false"
Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B"
HeaderStyle-BackColor="green"
AllowPaging="true" ShowFooter="true" OnPageIndexChanging="OnPaging" PageSize="10">
<Columns>
<asp:BoundField HeaderText="CustomerID" DataField="CustomerId" FooterText="Footer" />
<asp:BoundField HeaderText="Contact Name" DataField="ContactName" FooterText="Footer" />
<asp:BoundField HeaderText="Company Name" DataField="CompanyName" FooterText="Footer" />
</Columns>
<AlternatingRowStyle BackColor="#C2D69B" />
</asp:GridView>
参考:http://www.aspsnippets.com/Articles/Display-GridView-with-Empty-Message-and-Header-and-Footer-when-no-data-in-ASP.Net.aspx