ListView easy hide DataPager

protected void OnDataBound(object sender, EventArgs e)
{
    int page = 1;
    if (Request["page"] != null)
    {
        page = int.Parse(Request["page"]);
    }
    DataPagerPrevious.Visible = ((DataPagerPrevious.PageSize * page) > DataPagerPrevious.TotalRowCount && (page > 1));
    DataPagerNext.Visible = ((DataPagerNext.PageSize * page) < DataPagerNext.TotalRowCount);
}

<asp:ListView ID="listView" runat="server" OnDataBound="OnDataBound">

<asp:DataPager ID="DataPagerPrevious" runat="server" PagedControlID="listView" QueryStringField="page" PageSize="23">
    <Fields>
        <asp:NextPreviousPagerField ShowNextPageButton="false" />
    </Fields>
</asp:DataPager>

<asp:DataPager ID="DataPagerNext" runat="server" PagedControlID="listView" QueryStringField="page" PageSize="23">
    <Fields>
        <asp:NextPreviousPagerField ShowPreviousPageButton="false" />
    </Fields>
</asp:DataPager>

No hay comentarios:

Publicar un comentario