例如:
   设定:pagesize="1"  页数有9页。
   设定:pagesize="2"  页数为什么只有3页了?
   设定:pagesize="3"  页数就剩下可怜的1页了.....求解答

解决方案 »

  1.   

    pagesize: 每页显示几条。   你自己想想把!
      

  2.   


    检查你自己的数据源把!   RecordCount 是否设置正确? 自己代码的问题,不能怪pagesize  你自己没写好,搞出这两句话,  谁能知道你哪里出问题了! 真是的!
      

  3.   

    CS Code:         for (int i = 0; i < DataList1.Items.Count; i++)
            {
                HiddenField h = this.DataList1.Items[i].FindControl("Id") as HiddenField;
                DataSet dataset1 = BLL.hui(Int32.Parse(h.Value));
                PagedDataSource pdd = new PagedDataSource();
                pdd.DataSource = dataset1.Tables[0].DefaultView;
                pdd.AllowPaging = true;
                Wuqi.Webdiyer.AspNetPager AspNetPager2 = this.DataList1.Items[i].FindControl("AspNetPager2") as Wuqi.Webdiyer.AspNetPager;
                pdd.PageSize = AspNetPager2.PageSize;
                AspNetPager2.RecordCount = pdd.PageCount;
                pdd.CurrentPageIndex = AspNetPager2.CurrentPageIndex - 1;
                DataList DataList_Content = this.DataList1.Items[i].FindControl("DataList2") as DataList;
                DataList_Content.DataSource = pdd;
                DataList_Content.DataBind();        }Html Code: <webdiyer:AspNetPager ID="AspNetPager2" runat="server"  horizontalalign="Center" AlwaysShow="True" AlwaysShowFirstLastPageNumber="True"  PageSize="2"  OnPageChanging="AspNetPager2_PageChanging"  ></webdiyer:AspNetPager>
      

  4.   

    恕我愚笨,猜测下楼主的页面布局和效果:
    页面有datalist1这样的列表,datalist1里的每项都有自己的分页(AspNetPager2)
    datalist1列面中还套着列表datalist2
    好复杂的布局也就是说你页面里的AspNetPager2是一个TemplateField,并且有好多个AspNetPager2
      

  5.   


    你猜测的我想笑,但对楼主没别的意思,不要误会,只是觉的他说的有点搞笑!  你应该把FOR 去掉,分页放外面,一个就够,然后设置两步,就可以分页了!
      

  6.   

    楼上的很聪明,差不多是这样子。datalist1里面住着datalist2,现在是分别给这两个datalist分页,上面的代码是给datalist2分页的
      

  7.   

    把for去掉怎么样读取数据啊,datalist2要根据datalist1的ID填充数据的,求指教。真心没别的意思。
      

  8.   

    这是2个datalist分页的代码,求改,谢谢。真心觉得好乱。  
      public void fenye()
        {        DataSet dataset = BLL.fenye();
            PagedDataSource pd = new PagedDataSource();
            pd.DataSource = dataset.Tables[0].DefaultView;
            pd.AllowPaging = true;
            pd.PageSize = AspNetPager1.PageSize;
            AspNetPager1.RecordCount = pd.PageCount;
            pd.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            DataList1.DataSource = pd;
            DataList1.DataBind();        for (int i = 0; i < DataList1.Items.Count; i++)
            {
                HiddenField h = this.DataList1.Items[i].FindControl("Id") as HiddenField;
                DataSet dataset1 = BLL.hui(Int32.Parse(h.Value));
                PagedDataSource pdd = new PagedDataSource();
                pdd.DataSource = dataset1.Tables[0].DefaultView;
                pdd.AllowPaging = true;
                Wuqi.Webdiyer.AspNetPager AspNetPager2 = this.DataList1.Items[i].FindControl("AspNetPager2") as Wuqi.Webdiyer.AspNetPager;
                pdd.PageSize = AspNetPager2.PageSize;
                AspNetPager2.RecordCount = pdd.PageCount;
                pdd.CurrentPageIndex = AspNetPager2.CurrentPageIndex - 1;
                DataList DataList_Content = this.DataList1.Items[i].FindControl("DataList2") as DataList;
                DataList_Content.DataSource = pdd;
                DataList_Content.DataBind();        }
        }
      

  9.   

    贴上我使用这插件写过的这个分页代码//绑定的方法
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Data;
    using System.Web.UI.WebControls;
    using Wuqi.Webdiyer;
     public class GridviewControl
        {
            //当Gridview数据为空时显示的信息
            private static string EmptyText = "没有记录";        public GridviewControl()
            {        }        /// <summary>
            /// 防止PostBack后Gridview不能显示
            /// </summary>
            /// <param name="gridview"></param>
            public static void ResetGridView(GridView gridview)
            {
                //如果数据为空则重新构造Gridview
                if (gridview.Rows.Count == 1 && gridview.Rows[0].Cells[0].Text == EmptyText)
                {
                    int columnCount = gridview.Columns.Count;
                    gridview.Rows[0].Cells.Clear();
                    gridview.Rows[0].Cells.Add(new TableCell());
                    gridview.Rows[0].Cells[0].ColumnSpan = columnCount;
                    gridview.Rows[0].Cells[0].Text = EmptyText;
                    gridview.Rows[0].Cells[0].Style.Add("text-align", "center");
                }
            }        /// <summary>
            /// 绑定数据到GridView,当表格数据为空时显示表头
            /// </summary>
            /// <param name="gridview"></param>
            /// <param name="table"></param>
            public static void GridViewDataBind(GridView gridview, DataTable table,AspNetPager pager)
            {
                //记录为空重新构造Gridview
                if (table.Rows.Count == 0)
                {
                    table = table.Clone();
                    table.Rows.Add(table.NewRow());
                    gridview.DataSource = table;
                    gridview.DataBind();
                    int columnCount = gridview.Columns.Count;
                    gridview.Rows[0].Cells.Clear();
                    gridview.Rows[0].Cells.Add(new TableCell());
                    gridview.Rows[0].Cells[0].ColumnSpan = columnCount;
                    gridview.Rows[0].Cells[0].Text = EmptyText;
                    gridview.Rows[0].Cells[0].Style.Add("text-align", "center");
                    pager.Visible = false;
                }
                else
                {
                    //数据不为空直接绑定
                    /*--绑定分页--*/
                    PagedDataSource pds = new PagedDataSource();
                    pds.DataSource = table.DefaultView;//设置分页的数据源
                    pager.RecordCount = pds.Count;//AspNetPager1.RecordCount = ds.Tables[0].DefaultView.Count;等价//获取数据的条数
                    pds.AllowPaging = true;//设置允许分页
                    pds.CurrentPageIndex = pager.CurrentPageIndex - 1;//设置当前页的索引
                    pds.PageSize = pager.PageSize;//设置每页显示的页数
                    pager.CustomInfoHTML = string.Format("当前第<span style='color:red'>{0}</span>/{1}页 共<span style='color:red'>{2}</span>条记录 每页<span style='color:red'>{3}</span>条", new object[] { pager.CurrentPageIndex, pager.PageCount, pager.RecordCount, pager.PageSize });
                    gridview.DataSource = pds;
                    gridview.DataBind();
                    pager.Visible = true;
                }
                            //重新绑定取消选择
                gridview.SelectedIndex = -1;
            }
            public static void GridViewDataBind(GridView gridview, DataTable table)
            {
                //记录为空重新构造Gridview
                if (table.Rows.Count == 0)
                {
                    table = table.Clone();
                    table.Rows.Add(table.NewRow());
                    gridview.DataSource = table;
                    gridview.DataBind();
                    int columnCount = gridview.Columns.Count;
                    gridview.Rows[0].Cells.Clear();
                    gridview.Rows[0].Cells.Add(new TableCell());
                    gridview.Rows[0].Cells[0].ColumnSpan = columnCount;
                    gridview.Rows[0].Cells[0].Text = EmptyText;
                    gridview.Rows[0].Cells[0].Style.Add("text-align", "center");
                }
                else
                {
                    //数据不为空直接绑定                gridview.DataSource = table;
                    gridview.DataBind();
                }
                //重新绑定取消选择
                gridview.SelectedIndex = -1;
            }
        }
    使用的代码//前台在gridview后面加这个是分页控件的位置
      <webdiyer:AspNetPager ID="pager" runat="server" PageSize="15" 
                CssClass="ui-pager" CustomInfoClass="left"
                         FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" 
                ShowCustomInfoSection="Left" CurrentPageButtonPosition="Beginning" 
                PageIndexBoxType="DropDownList" ShowMoreButtons="False" ShowPageIndex="False" 
                ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页" 
                TextBeforePageIndexBox="转到" FirstLastButtonsClass="ui-button-text" 
                PrevNextButtonsClass="ui-button-text" CustomInfoStyle="" 
                Font-Underline="False" onpagechanging="pager_PageChanging" 
                ShowBoxThreshold="20" SubmitButtonClass="ui-select" >
            </webdiyer:AspNetPager>
    //绑定方法和事件
       protected void pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
            {
                pager.CurrentPageIndex = e.NewPageIndex;
    //这里再绑定下数据
    }
      

  10.   

    把分页的那几行写在for循环外面试试
      

  11.   

    写在外面不行的吧,要靠for读数据的。怎么写啊...