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,它同时也自带了 ...
随机推荐
- Android WebView与JavaScript交互操作(Demo)
应用场景: 为了使Android移动项目能够在较短的时间内完成开发,同时降低技术人员开发的成本投入,往往会采用Hybrid APP的开发模式.相关Hybrid APP(混合型应用)参看:http:// ...
- SQL Server 之登录
1:SQL Server 是Microsoft 公司推出的关系型数据库管理系统. 安装好后,开始登录. 2:几种登录方式: (1):服务器名称: ①: . :代表本地服务器 ②: local :代表本 ...
- C++ 三种工厂模式
工厂模式是将带有继承于基类的子类的创建过程交于一个工厂来创建,通过赋予不同的创建标识来创建不同的子类. 基于自己的理解和使用这里巩固一下工厂模式. 我们的项目目前使用最多的是简单工厂模式,不过其他两种 ...
- zencart安装第三步出现空白
问题描述:在安装zencart时,在第三步同意协议,然后点击下一步时,页面经过漫长的等待后就显示空白. 解决方法:打开php.ini,将max_execution_time = 30 -> ma ...
- ios网络:应用一个请求的7个步骤
Splitting big tasks into small tasks is often one of the best ways to solve a problem. Thus, in the ...
- Change Homepage Logo
Open the following defination and changed them. 1. NEW_PS_LOGO (Image Type) - To change the logo.2. ...
- nginx 编译安装
一.安装nginx时必须先安装相应的编译工具yum -y install gcc gcc-c++ autoconf automakeyum -y install zlib zlib-devel ope ...
- PHP导出excel文件
现在教教你如何导入excel文件: 在我的文件储存里面有一个com文件夹的,将其解压放在ThinkPHP/Library/文件夹里面,然后就是写控制器啦!去调用这个插件: <?php names ...
- PHPExcel读取excel的多个sheet存入数据库
//批量导入文章 excel读取 public function importdata ( $filename, $tmp_name ) { //设置超时时间 set_time_limit(0); $ ...
- mysql中的 IN和FIND_IN_SET的查询问题
原来以为mysql可以进行这样的查询select id, list, name from table where 'daodao' IN (list); (一)注:1. table含有三个字 ...