AspNetPager 分页的详细用法(ASP.NET)
1.【添加AspNetPager.dll文件】
2.【使用方法】
public static DataTable GetRecord(SystemModel.Pager mt, ref int TotalPage, ref int TotalRecord){string sortType = mt.SortType == 1 ? " asc" : " desc";//查询总条数string _strCountSQL = "select count(" + mt.PrimaryKey + ") from " + mt.TableName + " where " + mt.Where;string _strPageSQl = "select top " + mt.PageSize + " " + mt.FiledList + " from " + mt.TableName + " where " + mt.PrimaryKey + " not in(select top " + mt.PageSize * (mt.PageIndex - 1) + " " + mt.PrimaryKey + " from " + mt.TableName + " where " + mt.Where + " order by " + mt.Order + sortType + "," + mt.PrimaryKey + " " + sortType + ") and " + mt.Where + " order by " + mt.Order + sortType + "," + mt.PrimaryKey + " " + sortType;if (mt.PageIndex == 1){_strPageSQl = "select top " + mt.PageIndex * mt.PageSize + " " + mt.FiledList + " from " + mt.TableName + " where " + mt.Where + " order by " + mt.Order + sortType + "," + mt.PrimaryKey + " " + sortType;}DataSet ds = DBUtility.AccessHelper.Query(_strPageSQl);TotalRecord = int.Parse(DBUtility.AccessHelper.GetSingle(_strCountSQL).ToString());TotalPage = TotalRecord % mt.PageSize == 0 ? TotalRecord / mt.PageSize : TotalRecord / mt.PageSize + 1;return ds.Tables[0];}
也可以使用存储过程分页,这里的参数要返回一共多少页,当前第几页。
create procedure home (@pagesize int, @pageindex int, @docount bit) as if(@docount=1) select count(*) from binfo else beginwith temptbl as ( SELECT ROW_NUMBER() OVER (ORDER BY time desc)AS Row, * from binfo O )SELECT * FROM temptbl where Row between (@pageindex-1)*@pagesize+1 and (@pageindex-1)*@pagesize+@pagesize end
3.【页面中使用】
index.asx页面:
<webdiyer:AspNetPager ID="Pager22" runat="server" AlwaysShow="true" Font-Size="12px"CurrentPageButtonClass="cpb" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"PrevPageText="上一页" CustomInfoTextAlign="Right" ShowPageIndexBox="Never" ShowCustomInfoSection="Left"CenterCurrentPageButton="True" ShowFirstLast="true" ReverseUrlPageIndex="True"Direction="LeftToRight" Width="100%" OnPageChanging="Pager_PageChanging" ForeColor="Black"NumericButtonCount="100"></webdiyer:AspNetPager>
具体参数,可以查下相关的属性。
index.aspx.cs
SystemModel.Pager mt = new SystemModel.Pager();mt.PageIndex = PageIndex;mt.PageSize =分页数量;mt.TableName =表名;mt.FiledList = 查询的内容,如*;mt.PrimaryKey = 主键;mt.Where =条件;if (HttpContext.Current.Request["id"] != null){mt.Where = mt.Where + " and fid=" + int.Parse(HttpContext.Current.Request["id"].ToString());}mt.Order = 排序字段;mt.SortType = 排序方式(1或2);mt.RecorderCount = 0;int TotalPage = 1;int TotalRecord = 0;dtNews = SystemBLL.Pager.GetRecord(mt, ref TotalPage, ref TotalRecord);if (dtNews.Rows.Count < 1){return;}DataView dv = dtNews.DefaultView;PagedDataSource pds = new PagedDataSource();pds.DataSource = dv;pds.AllowPaging = true;pds.CurrentPageIndex = Pager22.CurrentPageIndex - 1;pds.PageSize = Pager22.PageSize;this.Pager22.PageSize = mt.PageSize;this.Pager22.RecordCount = TotalRecord;this.Pager22.CustomInfoHTML = string.Format("共 {0} 页,当前第 {1} 页,共 {2} 条记录", TotalPage, PageIndex, TotalRecord);if (TotalRecord <= mt.PageSize){this.Pager22.Style.Add("display", "none");}else{this.Pager22.Style.Add("display", "block");}
这里只有常用的一些属性,还有自定义url css之类的
也支持mvc
更多属性请查看这里:http://www.webdiyer.com/aspnetpager/
效果:
转载于:https://www.cnblogs.com/vanteking/p/3927696.html
AspNetPager 分页的详细用法(ASP.NET)相关推荐
- AspNetPager分页控件
http://files.cnblogs.com/zhangweiguo3984/AspNetPager433.rar 分页是Web应用程序中最常用到的功能之一,在ASP.NET中,虽然自带了一个可以 ...
- Repeater使用 AspNetPager分页控件
一.AspNetPager分页控件 分页是Web应用程序中最常用到的功能之一,在ASP.NET中,虽然自带了一个可以分页的DataGrid(asp.net 1.1)和GridView(asp.net ...
- Word查找替换详细用法及通配符一览表
转载自:https://www.cnblogs.com/whchensir/p/5768030.html Word查找替换详细用法及通配符一览表 使用通配符 要查找"?"或者&qu ...
- python3的formatter_python中的formatter的详细用法
今天抽空学习了一下python中的string service中的formatter的相关用法,主要是为了让自己的代码看起来更加和谐,因为很多java或者c语言过来的开发者都不怎么爱使用python的 ...
- Android命令行工具logcat详细用法!
logcat是Android中一个命令行工具,可以用于得到程序的log信息. 见板凳详细说明! 本贴内容来自网络,引用网址为:http://hi.baidu.com/%C9%C1%D2%AB ...
- __declspec关键字详细用法
__declspec关键字详细用法 2009-01-21 16:23 __declspec用于指定所给定类型的实例的与Microsoft相关的存储方式.其它的有关存储方式的修饰符如static与ext ...
- mysql left/right join算法效率分析_mysql left join,right join,inner join超详细用法分析
MySQL left join,right join,inner join超详细用法分析 下面是例子分析 表A记录如下: aID aNum 1 a20050111 2 ...
- GridView 利用AspNetPager 分页时的自动编号
GridView 利用AspNetPager 分页时的自动编号 <%# (this.WillisPager1.CurrentPageIndex-1) * this.WillisPager1.Pa ...
- python sort怎么用,Linux Sort命令详细用法(有实例)
Linux Sort命令详细用法(有实例) sort是在Linux里非常常用的一个命令,管排序的,集中精力,五分钟搞定sort,现在开始! Linux sort命令进阶: 1 sort的工作原理 so ...
- vue性能优化-------vendor优化详细用法(瘦身),减小体积,引入cdn
vue性能优化-------vendor优化详细用法(瘦身),减小体积,引入cdn 原创ChrisWang_ 最后发布于2019-05-24 10:25:58 阅读数 1332 收藏 展开 vue性 ...
最新文章
- html语言文字闪烁,html+CSS3实现的文字闪烁特效
- MPB:华南农大王文策组-​水禽肠道食糜微生物脂多糖含量的检测
- 如何构建高性能web站点之:分布式缓存
- error和exception
- AIX errdemon 命令
- python将print内容输入txt_Python将矩阵写入txt文件,保持格式
- KVM虚拟机在Ubuntu16.04下的环境搭建
- 值类型和引用类型的区别[转]
- 生产计划排产计划的模式有哪几种?
- 重力传感事件应用之一 手机摇一摇(摇一次得一分)
- yyyy-mm-dd与yyyy-MM-dd的区别
- 5110. 近义词句子
- cadaver (davtest)
- 推荐一款绝对不能错过的 ORM 框架 dbVisitor,目前版本 4.3.0
- 基于手机蓝牙的arduino遥控小车
- 你知道产品经理和项目经理的区别有哪些吗?
- CentOS You need to be root to perform this command问题解决
- 绘制中国近海的sst分布图
- Python数据分析与机器学习45- 股票预测
- 涉密信息系统“三员”的三个层面
热门文章
- 欧路词典如何导入html,[转载]如何用欧路词典背单词?
- 【财富空间】UpHonest Capital:美国人工智能投资分析报告(精华版)
- js实现canvas在线画板
- 八数码问题c语言,启发式搜索算法解决八数码问题(C语言)
- DHCP报文抓包分析
- CSS学习(四)——字体样式,文本样式
- QT安装 and VS2019中安装QT插件
- python折叠代码_使用region注释,将代码块收(折叠)起来
- Windows命令之ftp命令
- ads pspice 导入_怎么由导入ADS中的pspice的参数模型得到器件模型?