ASP.NET分页
[代码][C#]代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/// <summary> /// 分页内容 /// </summary> /// <param name="size">页面大小</param> /// <param name="count">页面数量</param> /// <param name="currendIndex">当前页</param> /// <param name="pattern">url模式:demo.aspx?page={0}</param> /// <param name="target">窗口模式</param> /// <returns></returns> public static string get_pagenation( int size, int count, int currendIndex, string pattern, string target) { //1>打开窗口目标 target = string .IsNullOrEmpty(target) ? "_top" : target; //2>总页数 int pageCount = count / size; pageCount = pageCount * size == count ? pageCount : pageCount + 1; //3>分页内容 StringBuilder strHtml = new StringBuilder(); strHtml.Append( "<span class='pagenation'>" ); #region 首部处理 if (currendIndex > 1) { strHtml.AppendFormat( "<a href='1' target='{0}'>[首页]</a>" , target); strHtml.AppendFormat( "<a href='{0}' target='{1}'>[上一页]</a>" , string .Format(pattern, currendIndex - 1), target); } else { strHtml.Append( "<span class='disabled'>[首页]</span> <span class='disabled'>[上一页]</span>" ); } #endregion #region 中间部分 int i = 1; int right = (currendIndex + 4) > pageCount ? pageCount : currendIndex + 4; if (currendIndex > 6) { i = currendIndex - 5; } else { right = pageCount >= 10 ? 10 : pageCount; } for (; i <= right; i++) { if (i == currendIndex) { strHtml.AppendFormat( "<font class='current'>{0}</font>" , i); strHtml.AppendLine(); continue ; } strHtml.AppendFormat( "<a href='{0}' target='{1}'>[{2}]</a>" , string .Format(pattern, i), target, i); strHtml.AppendLine(); } #endregion #region 尾部处理 if (currendIndex == pageCount) { strHtml.Append( "<span class='disabled'>[下一页]</span><span class='disabled'>[末页]</span>" ); strHtml.AppendFormat( "总共({0})页" , pageCount); } else { strHtml.AppendFormat( "<a href='{0}' target='{1}'>[下一页]</a>" , string .Format(pattern, currendIndex + 1), target); strHtml.AppendFormat( "<a href='{0}' target='{1}'>[末页]</a>" , string .Format(pattern, pageCount), target); strHtml.AppendFormat( " <label>总共({0})页</label>" , pageCount); } #endregion strHtml.Append( "</span>" ); return strHtml.ToString(); } |
ASP.NET分页的更多相关文章
- asp.net分页控件
一.说明 AspNetPager.dll这个分页控件主要用于asp.net webform网站,现将整理代码如下 二.代码 1.首先在测试页面Default.aspx页面添加引用 <%@ Reg ...
- asp.net 分页-自己写分页控件
去年就发表过asp.net 分页-利用后台直接生成html分页 ,那种方法只是单纯的实现了分页,基本不能使用,那时就想写个自己的分页控件,无奈能力有限.最近有点时间了,就自己做出了这个分页控件.我承认 ...
- (转)asp.net分页存储过程
Asp.Net分页存储过程 SQL分页语句 一.比较万能的分页: sql代码: 1 2 3 select top 每页显示的记录数 * from topic where id not in (sel ...
- 《ASP.NET1200例》<asp:DataList>分页显示图片
aspx页面代码 <asp:DataList ID="dlPhoto" runat="server" Height="137px" W ...
- ASP.NET分页存储过程,解决搜索时丢失条件信息
存储过程: -- ============================================= -- Author: -- Create date: -- Description: 分页 ...
- 【asp.net爬虫】asp.NET分页控件抓取第n页数据 javascript:__doPostBack
最近在模拟HTTP请求抓取数据,但是服务器是asp.net开发的 分页控件代码 <tr> <td align="left">共 210&am ...
- ASP.NET - 分页
效果: SQL-存储过程(Paging): ROW_NUMBER() over(order by MessageDateTime desc) 其中的 MessageDateTime desc 代表的 ...
- ASP.NET分页正品—分页真
承接上篇博文<ASP.NET真假分页-假分页>:http://blog.csdn.net/u010773667/article/details/38845009,继续解说ASP.NE ...
- ASP.NET 分页+组合查询 练习
分页和组合查询都是通过拼接SQL语句到数据库查询进行实现 到汽车表(car)中查询 ,汽车表选取了“编号 code”,“车名 name”,“日期 time”,“油耗 oil ”,“马力 powers” ...
- asp.net分页之AJAX 分页
查询功能是开发中最重要的一个功能,大量数据的显示,我们用的最多的就是分页. 在ASP.NET 中有很多数据展现的控件,比如Repeater.GridView,用的最多的GridView,它同时也自带了 ...
随机推荐
- 简化对象extend拓展
发现对对象继承或拷贝的时候,总是要$点来点去好麻烦,我的解决办法如下: (function(){ Object.prototype.extend = function(o){ $.extend(tru ...
- iOS开发中view controller设置问题
- A planning attack on a commuter train carriage in Taipei
Last night an explosion on a commuter train carriage in Taipei Songshan railway station wounded at l ...
- Spring框架搭建遇到的问题汇总
1.The resource is not on the build path of a Java project 然后把相应的依赖加入构建路径 2.Type mismatch: cannot con ...
- box2d 遍历世界中 body 的方法
大家都知道,循环遍历有很多方法,在box2d中大家普遍使用while和for循环来遍历世界,那什么时候使用for,什么时候使用while呢? 当循环中不设计body删除的时候,使用for循环,即: C ...
- 安装minicom串口访问开发板
1. 安装minicom yum install minicom 2. 设置minicom minicom -s 选择“Serial port setup”,将“Serial Device”修改成 ...
- Ubuntu14.04进入文本模式方法
ubuntu 10.10以前的操作方法: 1 第一步,具体命令及操作如下: sudo vi /etc/init/rc-sysinit.conf env DEFAULT_RUNLEVEL=3 <- ...
- SQLServer中用户 'sa' 登录失败解决办法
今天下午,很奇怪的网站突然就打不开了,报错如下: “/”应用程序中的服务器错误. 用户 'sa' 登录失败. 说明: 执行当前 Web 请求期间,出现未处理的异常.请检查堆栈跟踪信息,以了解有关该错误 ...
- Silverlight IIs发布问题
1.在IIS上部署系统没有问题,在vs中链接oracle中出错(数据连接不成功,请检查该数据库是否已启动尝试加载oracle客户端时引发BadImageFormatException.如果在安装32位 ...
- Bootstrap Alert Auto Close
http://stackoverflow.com/questions/23101966/bootstrap-alert-auto-close http://jsfiddle.net/mfX57/ $( ...