public object http = HttpContext.Current.Request.QueryString["productclass"];
public int pager { set { ViewState["Pager"] = value; } get { return (int)ViewState["Pager"]; } } //声明pager属性 使用ViewState状态保持对象保存Pager的值
PagedDataSource pageddatasource;//声明分页数据源
private void pageDataBind()
{
object pindex = HttpContext.Current.Request.QueryString["pindex"];
pageddatasource = new PagedDataSource();//实例化分页数据源
pageddatasource.DataSource = (List
pageddatasource.AllowPaging = true;//分页数据源 是否使用分页功能
pageddatasource.PageSize = 9;//设置分页数据源项数据数目;
if (pindex != null)
{
if (!IsPostBack)
{
pageddatasource.CurrentPageIndex = Convert.ToInt32(pindex);//设置当前页
pager = pageddatasource.CurrentPageIndex;
}
else
{
pageddatasource.CurrentPageIndex = pager;
}
}
else
{
pageddatasource.CurrentPageIndex = pager;
}
this.thisPage.Text = "第 " + (pageddatasource.CurrentPageIndex + 1).ToString() + " 页";
this.pagecount.Text = "共 " + pageddatasource.PageCount.ToString() + " 页";
this.DataList1.DataSource = pageddatasource;//绑定pageddatasource分页数据源;
this.DataList1.DataBind();//执行绑定;
}
AllowPaging="True" PageSize="6"
pagesize是一页内有多少行信息
看看这个