AspNetPager分控件绑定组合好的DataSet,
这个Dataset是被组合好的.而AspNetPager好像必须要由SQL语句来绑定.
有没有那位这样做过.
把代码帖出来看下,谢谢了各位大哥.杂七杂八

解决方案 »

  1.   

      public void Bind()
        {
            DataTable dt = useraccess.GetList("").Tables[0];
            DataColumn dc = dt.Columns.Add("number", System.Type.GetType("System.String"));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["number"] = (i + 1).ToString();
            }
            DataView dv = dt.DefaultView;
            PagedDataSource pds = new PagedDataSource();
            AspNetPager1.RecordCount = dv.Count;
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.PageSize = AspNetPager1.PageSize;
            this.grduse.DataSource = pds;
            this.grduse.DataBind();
        }
      

  2.   

    主要是用2个属性
    一个是总行数,一个是数据源把你组合的新dataTABLE里的行数复制给RecordCount 
    DataTable dt = 你合并的数据
    AspNetPager1.RecordCount = dt.Rows.Count;其实数据源不变,以你先合成的为主
      

  3.   

    首先下载控件:AspNetPager.dll (108k)一、控件属性设置
     <webdiyer:aspnetpager id="Pager1" runat="server" horizontalalign="Right" FirstPageText="首页" LastPageText=" 尾页"
    NextPageText=" 后页" PrevPageText=" 前页" showcustominfosection="Left" width="100%" InputBoxStyle="width:19px"
    TextAfterInputBox="页" TextBeforeInputBox="转到第" CustomInfoHTML="共<font color='red'>%RecordCount%</font>条记录 每页<font color='red'>%PageSize%</font>条 第<font color='red'>%CurrentPageIndex%</font>页 共<font color='red'>%PageCount%</font>页" ShowPageIndex="False" ShowInputBox="Always" PageIndexBoxType="TextBox" AlwaysShow="True" InvalidPageIndexErrorMessage="没有数据" ShowBoxThreshold="2" ShowPageIndexBox="Auto" OnPageChanged="Pager1_PageChanged"></webdiyer:aspnetpager>
    二、分页绑定方法:
        public PagedDataSource getPage(DataTable ds)
        {
            this.Pager1.RecordCount = ds.Rows.Count;
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = ds.DefaultView;
            pds.AllowPaging = true;
            pds.CurrentPageIndex = Pager1.CurrentPageIndex - 1;
            pds.PageSize = Pager1.PageSize;
            return pds;
        }
    三、Gridview绑定控件:
        this.Gridpai.DataSource = this.getPage(da);
                this.Gridpai.DataBind();四、写AspNetPager.dll的pageChanged事件,(事件绑定的是获取DataTable的方法)我都是这样写的  dataset 跟gridview差不多  换一下就可以了
      

  4.   

    http://hi.baidu.com/zzxap/blog/item/83e3b3d015093588a0ec9cbc.html