AspNetPager分控件绑定组合好的DataSet,
这个Dataset是被组合好的.而AspNetPager好像必须要由SQL语句来绑定.
有没有那位这样做过.
把代码帖出来看下,谢谢了各位大哥.杂七杂八
这个Dataset是被组合好的.而AspNetPager好像必须要由SQL语句来绑定.
有没有那位这样做过.
把代码帖出来看下,谢谢了各位大哥.杂七杂八
解决方案 »
- Wizard控件怎么运行后刚出来的不是第一步是第三步呢
- ADO.NET中五大主要对象
- 请教两个UpdatePanel局部刷新的问题
- 如何自定义绑定gridview
- 一个古老的网页问题!
- 指点一下,怎获得客户端的ip啊
- 关于checkbox在datagrid中触发事件的问题,百思不得其解,忘高手指点迷津!谢谢啦!
- 如何在DataSet.Table["rsda"]中查询符合条件的记录?
- girdview 在Firefox 下的分页
- 在IIS中怎么设置HTTP代码,使得自动导向到相应的HTTP错误处理页面?
- 【求助!!!!!! 如何实现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差不多 换一下就可以了