当 ASP 中 GridView 为空时,PagerTemplate 不显示

发布于 2024-11-02 10:43:00 字数 1017 浏览 9 评论 0原文

我正在尝试创建一个小型 ASP.NET 应用程序,其中有一个 GridView,其中包含从数据库访问的数据。我还有一个 PagerTemplate,它具有 LinkBut​​tons,允许我向数据库添加新记录。但是,当表为空时,我无法看到我的寻呼机控件,但如果表中只有一个条目,我就没有问题。有什么方法可以让我始终显示 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情空心 2024-11-09 10:43:00

将 PagerTemplate 的内容添加到 EmptyDataTemplate 是一个解决方案..

Add the contents of the PagerTemplate to the EmptyDataTemplate is a solution ..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文