asp.net高效分页的办法

分页控件:DataPager控件
1、微软封装的控件中,只有listview控件能使用DataPager控件。
2、只有实现了IPageableItemContauner接口的控件才能使用DataPager控件。
3、Datapager控件的显示风格是在Fields中的字段设置,可以组合使用数字页号和上下页风格等,也可混合使用。


  使用ListView 高效率分页:
1、给结果集编号
select id, Username,Comment, row_number() over(order by ID)rownum from T_UserComment


2、取第多少条数据到第多少条数据做为一页,进行分页。
select * from (select id, Username,Comment, row_number() over(order by ID)rownum from T_UserComment)t where t.rownum <=10 and t.rownum>=1


3、配置数据集,添加两个方法:查询数据条数Select count(*) from T_UserComment、查询分页的数据(从多少条数据到多少条数据进行分页) 
select * from (select id, Username,Comment, row_number() over(order by ID)rownum from T_UserComment)t where t.rownum >@startRowIndex and t.rownum>=@startRowIndex+@maximumRows
 生成数据集,


4、(注意:先按常规配置,然后配置Listview以后再详细配置ObjectDataSource否则Listview会出现异常)配置ObjectDataSource,添加SelectCountMethod(查询数量)属性,SelectMothod(每页的数据),启用EnablePaging属性.


5、配置listview,OK。


实例见:E:\newd\我的文档\Visual Studio 2010\WebSites\数据控件\ListView高效分页
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值