AspNetPager 分页的详细用法(ASP.NET)
1.【添加AspNetPager.dll文件】
2.【使用方法】
public static DataTable GetRecord(SystemModel.Pager mt, ref int TotalPage, ref int TotalRecord)
{
string sortType = mt.SortType == ? " 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 - ) + " " + 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 == )
{
_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 == ? TotalRecord / mt.PageSize : TotalRecord / mt.PageSize + ;
return ds.Tables[];
}
也可以使用存储过程分页,这里的参数要返回一共多少页,当前第几页。
create procedure home
(@pagesize int,
@pageindex int,
@docount bit)
as
if(@docount=1)
select count(*) from binfo
else
begin
with 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 <)
{
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/
效果:

AspNetPager 分页的详细用法(ASP.NET)的更多相关文章
- 【转】AspNetPager分页控件用法
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码: 1.首先到www.w ...
- AspNetPager分页控件
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:1.首先到www.we ...
- IFRAM的详细用法
IFRAM的详细用法: IFRAM的详细用法: <IFRAME>用于设置文本或图形的浮动图文框或容器. BORDER <IFRAME BORDER="3"& ...
- 【Bootstrap3.0建站笔记三】AspNetPager分页,每一列都可排序
1.AspNetPager分页,实现每一列都可排序: (1).须要将默认排序字段放在HTML页面中. (2).排序字段放置为td节点的属性. 如图: 实现的效果 ...
- C# Repeater、webdiyer:AspNetPager分页 AspNetPager分页样式
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/vaecnfeilong/article/details/32712611 AspNetPager分页 ...
- heckboxlist详细用法、checkboxlist用法、checkboxlist
heckboxlist详细用法.checkboxlist用法.checkboxlist for (int i = 0; i < CheckBoxList1.Items.Count; i++) { ...
- PagedDataSource数据绑定控件和AspNetPager分页控件结合使用列表分页
1.引用AspNetPager.dll. 2.放置Repeater数据绑定控件. <asp:Repeater ID="Repeater1" runat="serve ...
- jquery jtemplates.js模板渲染引擎的详细用法第一篇
jquery jtemplates.js模板渲染引擎的详细用法第一篇 Author:ching Date:2016-06-29 jTemplates是一个基于JQuery的模板引擎插件,功能强大,有了 ...
- ExtJS ComboBox 下拉列表详细用法
ExtJS ComboBox 下拉列表详细用法 标签: combobox 2015-06-14 23:23 5171人阅读 评论(2) 收藏 举报 分类: ExtJS(32) 目录(?)[+] ...
随机推荐
- 免费的ERP真的那么可怕?请少一些偏见!
为什么说这个话题,因为看到了太多关于对免费ERP的偏见,也许这也只是那些卖软件的营销策略:从事这个行业的人,应该能看出其中的端倪,但是对于吃瓜群众来说,那就真是误导了... 所以今天发表下自己的看法, ...
- 代写编程的作业、笔试题、课程设计,包括但不限于C/C++/Python
代写编程作业/笔试题/课程设计,包括但不限于C/C++/Python 先写代码再给钱,不要任何定金!价钱公道,具体见图,诚信第一! (截止2016-11-22已接12单,顺利完成!后文有成功交付的聊天 ...
- 徒手用Java来写个Web服务器和框架吧<第三章:Service的实现和注册>
徒手用Java来写个Web服务器和框架吧<第一章:NIO篇> 徒手用Java来写个Web服务器和框架吧<第二章:Request和Response> 这一章先把Web框架的功能说 ...
- ajax删除数据(不跳转页面)
以前我们讲的删除是利用嵌入php代码,跳转到另一个页面,从而降低了删除速度,但我们今天讲的利用ajax不仅可以达到不跳页面快速删除,并且能添加特效来美化页面. AJAX = 异步 JavaScript ...
- 每天一个Linux命令 8
yum 光盘yum源搭建好处:不需要上网,省去许多网络yum源下载所需的时间,安装速度会大大增加.缺点:yum源不一定是最新的 1.打开虚拟机,加载光盘镜像,进入Linux系统,挂载光盘.2. 让网络 ...
- 腾讯云数据库团队:浅谈如何对MySQL内核进行深度优化
作者介绍:简怀兵,腾讯云数据库团队高级工程师,负责腾讯云CDB内核及基础设施建设:先后供职于Thomson Reuters和YY等公司,PTimeDB作者,曾获一项发明专利:从事MySQL内核开发工作 ...
- 3856: Monster
3856: Monster Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 351 Solved: 161[Submit][Status][Discuss ...
- SEO-站外优化规范
站外优化规范 新站 前期(提高网站曝光率<信息发布平台>) 一. 分类目录信息发布 二. 黄页网信息发布 三. 友链平台信息发布 四. 各大论坛引蜘蛛区信息发布 五. 网址提交 六. 社区 ...
- react.js 获取真实的DOM节点
为了获取真实的dom节点,文本输入框必须有一个 ref 属性,然后 this.refs.[refName] 就会返回这个真实的 DOM 节点. var MyComponent = React.crea ...
- js 的DOM操作 2017-03-21
DOM(document object model) 文档对象模型 BOM(browse object model) 针对浏览器(如:弹出的窗口,滚动条等) 一.操作对象(注意大小写:注意elemen ...