一个分页程序出现了这样一个错误,原来问题出在页码上:
DataSet ds = SqlHelper.ExecuteDateSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "select Article_Id,Article_Title,Article_Date from Article " + strwhere + " order by Article_Date ", null);
//DataSet ds = GetArticleInfo("Article", "Article_Id,Article_Title,Article_Date", pageSize, NowPage, 0, "Article_Date", 1, strwhere, "Article_Id", "", F_ID, ref pageCount, ref Counts);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 13;
this.lb_PageSize.Text = pds.PageSize.ToString();
pds.CurrentPageIndex = Convert.ToInt32(this.labpage.Text) - 1;
Re_Article_List.DataSource = pds;
labcountpage.Text = pds.PageCount.ToString();
labpage.Text = Convert.ToString(pds.CurrentPageIndex + 1);
this.lbtnpritpage.Enabled = true;
this.lbtnfirstpage.Enabled = true;
this.lbtnnextpage.Enabled = true;
this.lbtndownpage.Enabled = true;
if (pds.CurrentPageIndex < 1)
{
this.lbtnpritpage.Enabled = false;
this.lbtnfirstpage.Enabled = false;
}
if (pds.CurrentPageIndex == pds.PageCount - 1)
{
this.lbtnnextpage.Enabled = false;
this.lbtndownpage.Enabled = false;
}
this.Re_Article_List.DataBind();
原来我把labpage初始化成了0,0-1=-1,难道就出现了这样的错误,可悲的是我花了将进两小时才搞定它,真是晕倒