急....AspNetPager分控件绑定组合好的DataSet AspNetPager分控件绑定组合好的DataSet,这个Dataset是被组合好的.而AspNetPager好像必须要由SQL语句来绑定.有没有那位这样做过.把代码帖出来看下,谢谢了各位大哥.杂七杂八 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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个属性一个是总行数,一个是数据源把你组合的新dataTABLE里的行数复制给RecordCount DataTable dt = 你合并的数据AspNetPager1.RecordCount = dt.Rows.Count;其实数据源不变,以你先合成的为主 首先下载控件: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差不多 换一下就可以了 http://hi.baidu.com/zzxap/blog/item/83e3b3d015093588a0ec9cbc.html 文章发布的问题 DataView问题小弟在此多谢高手帮忙 IE6 7 8 OR FIREFOX2 3 谁让WEB更精彩? 有关页面跳转错误问题,急!!! 在网站中,如何将表格等非纯文本文件传到数据库中? 重装IIS后出现的问题???? 为什么我的设计面不见了? 如何在ASP.NET中写中文到数据库里面 Rereater精通者进 1年经验者进 关于Columns.Add的问题 【求助!!!!!! 如何实现GridViewRow中,实现单击背景色发生改变,同时调用后台带String参数代码】 安装程序无法复制custsat.dll文件,这是怎么回事?
{
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();
}
一个是总行数,一个是数据源把你组合的新dataTABLE里的行数复制给RecordCount
DataTable dt = 你合并的数据
AspNetPager1.RecordCount = dt.Rows.Count;其实数据源不变,以你先合成的为主
<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差不多 换一下就可以了