.net datalist实现了分页,但只显示第一页的数据
intcurpage=Convert.ToInt32(this.labPage.Text);PagedDataSourceps=newPagedDataSource();...
int curpage = Convert.ToInt32(this.labPage.Text);
PagedDataSource ps = new PagedDataSource();
ds = tb_article.query_all();
ps.DataSource = ds.Tables[0].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = 1; //显示的数量
this.DataList1.DataSource = ps;
this.DataList1.DataKeyField = "id";
this.DataList1.DataBind();
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;//不显示第一页按钮
this.lnkbtnUp.Enabled = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;//不显示下一页
this.lnkbtnBack.Enabled = false;//不显示最后一页
}
this.labBackPage.Text = Convert.ToString(ps.PageCount); 展开
PagedDataSource ps = new PagedDataSource();
ds = tb_article.query_all();
ps.DataSource = ds.Tables[0].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = 1; //显示的数量
this.DataList1.DataSource = ps;
this.DataList1.DataKeyField = "id";
this.DataList1.DataBind();
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;//不显示第一页按钮
this.lnkbtnUp.Enabled = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;//不显示下一页
this.lnkbtnBack.Enabled = false;//不显示最后一页
}
this.labBackPage.Text = Convert.ToString(ps.PageCount); 展开
展开全部
没看见你修改页码curpage 的地方,是不是这部分没设置?可以参考下面链接的代码
http://www.cnblogs.com/jory/archive/2012/05/07/2487128.html
http://www.cnblogs.com/jory/archive/2012/05/07/2487128.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询