无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount。源错误: 
行 268:
行 269:                DataGrid1.DataSource = dv;
行 270:                DataGrid1.DataBind();
行 271:                string counmpage;
行 272:                //分页按钮
 

解决方案 »

  1.   

    2楼大哥做法我有,我想问的是问题出错在哪里?是SQL语句出错还是其他的什么原因导致的呢?
      

  2.   


        /// <summary>
        /// 绑定新闻
        /// </summary>
        protected void DBView()
        {        DataTable newsList = TuanNewsService.GetAllNews().Tables[0];
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = newsList.DefaultView;
            anpTuanNews.RecordCount = newsList.Rows.Count;
            pds.CurrentPageIndex = anpTuanNews.CurrentPageIndex - 1;
            pds.PageSize = anpTuanNews.PageSize;
            pds.AllowPaging = true;
            this.rptTypeNews.DataSource = pds;
            this.rptTypeNews.DataBind();        //var newsList = SqlHelper.GetDataSet(sql).Tables[0];
        }
      

  3.   

    我看,SQL语句应该不是报这样的错。
    看来是分页控件属性设置问题吧
      

  4.   

    参考http://david8k.cnblogs.com/archive/2006/02/14/330611.aspx
      

  5.   

    看看你的前台分页控件、后台数据源绑定方法、还有onpagechanged事件
      

  6.   

     我的前台分页控件就是Button (上一页)后台的绑定,(直接在Button下)写:            DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1;
                DataGrid1.DataBind();
                DataSource();
    OnPageChanged事件是这样写得
     protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
            {
                DataGrid1.CurrentPageIndex = e.NewPageIndex; ;
                DataSource();
            }
      

  7.   

    int totalRecords = 0; anp.RecordCount = totalRecords;            if (totalRecords == 0)
                    Message = "暂无记录!";            rpt_CirNoList.DataSource = list_no;
                rpt_CirNoList.DataBind();你判断下,如果数据为空的话提示,不为空的时候就绑定数据。
      

  8.   

    从报错来看是页面的参数错了,你可以做个判断
    if (Request.QueryString["pageid"] != null && Convert.ToInt32(Request.QueryString["pageid"]) > 0 && Convert.ToInt32(Request.QueryString["pageid"]) <= pds.PageCount)
                    {
                        pageindex = Convert.ToInt32(Request.QueryString["pageid"]);
                    }
                    else if (Convert.ToInt32(Request.QueryString["pageid"]) > pds.PageCount)
                    {
                        pageindex = pds.PageCount;
                    }
                    else
                    {
                        pageindex = 1;
                    }