AspnetPager分页控件的使用
2007-09-28 15:46
393 查看
用了几次吴旗娃的分页控件,觉得蛮好用的,但每次用都因为没有保存代码,所以后来再想用的时候就没有了.郁闷之极.
看吴旗娃的例子对于我这个新手来说还有一定的难度,希望以后能看懂吧, 现在就把自己通过Google 、Baidu搜索出的解决方法和吴旗娃的文档结合起来所得到分页代码收藏起来,以备后用! 都是通过测试,已经成功了的!
一、
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pagesize="3"></webdiyer:aspnetpager>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void BindData()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PagedDataSource pds = new PagedDataSource();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.AllowPaging = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.PageSize = AspNetPager1.PageSize;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataView dv = (DataView)GBDS.Select(DataSourceSelectArguments.Empty);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.DataSource = dv;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GB.DataSource = pds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GB.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BindData();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
protected void GBDS_Selected(object sender, SqlDataSourceStatusEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AspNetPager1.RecordCount = e.AffectedRows;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
其中的GB为GridView控件,GBDS为SqlDatasource控件,这个示例是在sqldatasource控件通过向导与数据库进行连接的。
二、
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//绑定分页控件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
AspNetPager1.RecordCount = source.Count;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PagedDataSource pds = new PagedDataSource();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.DataSource = source;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.AllowPaging = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.PageSize = AspNetPager1.PageSize; ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
dgMailList.DataSource = pds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
dgMailList.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<webdiyer:aspnetpager id="AspNetPager1" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
OnPageChanged="AspNetPager1_PageChanged" PageSize="1"></webdiyer:aspnetpager></center>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
这个示例是采用的存储过程检索数据然后返回DataTable。再将表转换成视图。。。。。。。
看吴旗娃的例子对于我这个新手来说还有一定的难度,希望以后能看懂吧, 现在就把自己通过Google 、Baidu搜索出的解决方法和吴旗娃的文档结合起来所得到分页代码收藏起来,以备后用! 都是通过测试,已经成功了的!
一、
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pagesize="3"></webdiyer:aspnetpager>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void BindData()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PagedDataSource pds = new PagedDataSource();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.AllowPaging = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.PageSize = AspNetPager1.PageSize;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataView dv = (DataView)GBDS.Select(DataSourceSelectArguments.Empty);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pds.DataSource = dv;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GB.DataSource = pds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GB.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BindData();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
protected void GBDS_Selected(object sender, SqlDataSourceStatusEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AspNetPager1.RecordCount = e.AffectedRows;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
其中的GB为GridView控件,GBDS为SqlDatasource控件,这个示例是在sqldatasource控件通过向导与数据库进行连接的。
二、
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//绑定分页控件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
AspNetPager1.RecordCount = source.Count;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PagedDataSource pds = new PagedDataSource();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.DataSource = source;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.AllowPaging = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pds.PageSize = AspNetPager1.PageSize; ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
dgMailList.DataSource = pds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
dgMailList.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<webdiyer:aspnetpager id="AspNetPager1" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
OnPageChanged="AspNetPager1_PageChanged" PageSize="1"></webdiyer:aspnetpager></center>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
这个示例是采用的存储过程检索数据然后返回DataTable。再将表转换成视图。。。。。。。
相关文章推荐
- 关于使用AspNetPager分页控件的小结[待续...]
- 使用AspNetPager分页控件、分页存储过程及用户控件基类实现的完美分页功能
- AspNetPager分页控件的一般使用方法
- asp.net 分页控件AspNetPager的使用
- asp.net分页控件AspNetPager的使用,使用传统分页和存储过程分页
- AspNetPager分页控件的使用
- 如何使用AspNetPager分页控件和ObjectDataSource控件进行分页
- asp.net下Repeater使用 AspNetPager分页控件
- AspNetPager控件分页使用方法
- NHibernate之 Castle.ActiveRecord中使用分页控件AspNetPager
- 《程序员的第一年》---------- 今天学习了一下aspnetpager分页控件的使用
- asp.net下Repeater使用 AspNetPager分页控件
- 使用AspNetPager控件实现GridView分页
- asp.net分页控件AspNetPager的使用,使用传统分页和存储过程分页
- ASP.NET中DataList控件和AspNetPager控件的组合使用并实现分页
- ASP.NET-AspNetPager分页控件完整使用方法
- 使用AspNetPager分页控件、分页存储过程及用户控件基类实现的完美分页功能
- AspNetPager控件分页使用方法
- 使用AspNetPager控件分页
- AspNetPager分页控件的使用