求分页方法Repeater
AspnetPager的用法 我要对 Repeater 进行分页。 现在有一个 dataTable dt=count.selectAll();//从另外的地方直接取得一张表。
程序代码:
//声明一个页面数据源,用来缓存信息列表(所有的信息)
PagedDataSource pds = new PagedDataSource();
public void DataBind()
{
pds.DataSource = noticeMessage.getAllLaw();
pds.AllowPaging = true;
pds.PageSize = 3;
pds.CurrentPageIndex = Pager;
this.Label4.Text = "第 " + (pds.CurrentPageIndex + 1) + " 页,共 " + (pds.PageCount) + " 页";
//设置PageDown / PageUp 按钮的状态
this.Button3.Enabled = true;
this.Button4.Enabled = true;
if (pds.IsFirstPage)
this.Button3.Enabled = false;
if (pds.IsLastPage)
this.Button4.Enabled = false;
//控件绑定信息
this.rep.DataSource = pds;
this.rep.DataBind();
}
//声明一个变量保存当前页码
public int Pager
{
get { return (int)ViewState["Pager"]; }
set { ViewState["Pager"] = value; }
}