页面:
DataList省略
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" 
                            onpagechanging="AspNetPager1_PageChanging">
                        </webdiyer:AspNetPager>CS代码:
/// <summary>
        /// 绑定产品信息
        /// </summary>
        private void ProductSetBind()
        {
            Wsb.BLL.Product bll = new Wsb.BLL.Product();
            DataSet ds = new DataSet();
            if (Request["IdNo"] == null)
            {
                ds = bll.GetList(new Guid("43FE3705-935C-4ACC-8DC1-36B7A0293D81"));//雅玉礼品
            }
            else
            {
                ds = bll.GetSubList(new Guid(Request["IdNo"].ToString()));
            }
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = ds.Tables[0].DefaultView;
            pds.AllowPaging = true;
            pds.PageSize = 3;            AspNetPager1.RecordCount = ds.Tables[0].DefaultView.Count;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex;
            dl_DataInfo.DataSource = pds;
            dl_DataInfo.DataBind();
        }        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            ProductSetBind();
        }总共是11条记录,每页显示3条记录,那就应该分成4页,而现在只有2页,这是怎么回事呢?

解决方案 »

  1.   

    AspNetPager1.RecordCount = ds.Tables[0].DefaultView.Count; 
    好像不能这么写。
    应该单独写个方法把数据总数读出来
    你这样只是读出一也的数据
    而且好像pagesize、pageindex没有传进去
    你看下aspnetpager的例子吧
      

  2.   

    问题应该是你没有把AspNetpager的PageSize属性设置为3,而它默认是10,所以11记录只能分两页,应该在前台把AspNetPager的PageSize设为3,同时后台pds.PageSize = 3;改为pds.PageSize = AspNetPager1.PageSize以便统一.