当 ASP 中 GridView 为空时,PagerTemplate 不显示
我正在尝试创建一个小型 ASP.NET 应用程序,其中有一个 GridView,其中包含从数据库访问的数据。我还有一个 PagerTemplate,它具有 LinkButtons,允许我向数据库添加新记录。但是,当表为空时,我无法看到我的寻呼机控件,但如果表中只有一个条目,我就没有问题。有什么方法可以让我始终显示 PagerTemplate.请是我的代码示例。
<asp:GridView ID="gvResults" runat="server" PageSize="10" AutoGenerateColumns="false"
CssClass="tablestyle" AllowPaging="true" ShowHeaderWhenEmpty="true">
<AlternatingRowStyle CssClass="altrowstyle" />
<HeaderStyle CssClass="headerstyle" />
<RowStyle CssClass="rowstyle" />
...
<PagerTemplate>
<div class="pagers">
<table class="pagerTable">
<tr>
<td align="left">
<asp:LinkButton ID="btnInsertMediaRate" runat="server" Text="Add New" OnClick="btnNewMediaRate_Click"></asp:LinkButton>
</td>
</tr>
</table>
</div>
</PagerTemplate>
</asp:GridView>
预先感谢您的帮助。
I am trying to make a small ASP.NET application where I have a GridView with data being accessed from the database. I also have a PagerTemplate that has LinkButtons that allow me to add in a new record to the database. However when the table is empty I am not able to see my Pager controls, but I have no issues if there is a single entry in the table. Is there any way that I can always display the PagerTemplate. Please is a sample of my code.
<asp:GridView ID="gvResults" runat="server" PageSize="10" AutoGenerateColumns="false"
CssClass="tablestyle" AllowPaging="true" ShowHeaderWhenEmpty="true">
<AlternatingRowStyle CssClass="altrowstyle" />
<HeaderStyle CssClass="headerstyle" />
<RowStyle CssClass="rowstyle" />
...
<PagerTemplate>
<div class="pagers">
<table class="pagerTable">
<tr>
<td align="left">
<asp:LinkButton ID="btnInsertMediaRate" runat="server" Text="Add New" OnClick="btnNewMediaRate_Click"></asp:LinkButton>
</td>
</tr>
</table>
</div>
</PagerTemplate>
</asp:GridView>
Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 PagerTemplate 的内容添加到 EmptyDataTemplate 是一个解决方案..
Add the contents of the PagerTemplate to the EmptyDataTemplate is a solution ..