Fork me on GitHub

AspNetPager demo - Simple postback

This sample demonstrates the basic functionality of AspNetPager, help you understand how it works.

In order to paging use AspNetPager, you only need to set its RecordCount property value and handle PageChanged event, you can show or bind data in this event handler.

Click paging buttons below to view paging effect:


(check this checkbox will only fire PageChanging event,PageChanged event will not be triggered)

AspNetPager running affect:

Cloned AspNetPager:

Basic.aspx:

<p><asp:Label runat="server" ID="label1" ForeColor="red" EnableViewState="false"></asp:Label>
<br /><asp:Label runat="server" ID="label2" ForeColor="red" EnableViewState="false"></asp:Label></p>
    <asp:CheckBox ID="CheckBox1" runat="server" Text="Cancel Paging" />(check this checkbox will only fire PageChanging event,PageChanged event will not be triggered)
    <p>AspNetPager running affect: </p>
    <webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged" 
    Width="100%" HorizontalAlign="center" AlwaysShowFirstLastPageNumber="true" PagingButtonSpacing="10"></webdiyer:aspnetpager>

    <p>Cloned AspNetPager: </p>
    <div><webdiyer:aspnetpager id="AspNetPager2" runat="server" CloneFrom="AspNetPager1"></webdiyer:aspnetpager></div>

Basic.aspx.cs:

using System;
using System.Web.UI;
using Wuqi.Webdiyer;

public partial class Basic_Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AspNetPager1.RecordCount = 288;
        }
    }


    protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
    {
        if (CheckBox1.Checked)
            e.Cancel = true;
        label1.Text = "PageChanging event fired,value of the NewPageIndex is " + e.NewPageIndex;
    }

    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
        label2.Text = "PageChanged event fired,current page index is " + AspNetPager1.CurrentPageIndex;
    }
}