前台:
代码
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" BackColor="#EEEEEE"
CenterCurrentPageButton="True"
CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条"
FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
onpagechanging="AspNetPager1_PageChanging" PageIndexBoxType="DropDownList"
PageSize="20" PrevPageText="上一页" ShowCustomInfoSection="Left"
ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页"
TextBeforePageIndexBox="转到">
</webdiyer:AspNetPager>
后台:
代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
user l = new user();
List<user> m = l.GetList();
AspNetPager1.RecordCount = m.Count;
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = m;
grdY_user.DataSource = pds;
grdY_user.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
Bind();
}