Search code examples
asp.netvisual-studio-2010gridviewpagertemplate

PagerTemplate does not show when GridView is empty in ASP


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.


Solution

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