pagesize已经设置好了,比如4,但有7条记录的话,仍然一页显示7个,AspNetPager上面的页码数会变成2,但是点2会出错,这是什么原因?

解决方案 »

  1.   

    代码问题?说具体点,只要设置好PAGESIZE,datalist就会按照设置的值自动分么?
      

  2.   

    private void List()
    {
    this.DataList1.DataSource=this.GetCommentTable();
    this.DataList1.DataBind(); //动态设置用户自定义文本内容
    AspNetPager1.CustomInfoText="作品总数:<b>"+AspNetPager1.RecordCount.ToString()+"</b>";
    AspNetPager1.CustomInfoText+=" 总页数:<b>"+AspNetPager1.PageCount.ToString()+"</b>";
    AspNetPager1.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
    }
    private DataTable GetCommentTable()
    {
    SqlDataAdapter cmd=new SqlDataAdapter(cmdtext,con);
    int startRecord=this.AspNetPager1.PageSize*(this.AspNetPager1.CurrentPageIndex-1);
    int maxRecords=this.AspNetPager1.PageSize;

    DataSet ds=new DataSet();
    cmd.Fill(ds,startRecord,maxRecords,"topictable"); return ds.Tables[0];
    }