PagerTemplate does not show when GridView is empty in ASP

柔情痞子 提交于 2019-12-11 07:06:15

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/5719161/pagertemplate-does-not-show-when-gridview-is-empty-in-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!