AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件:

<div class="oa-el-grid-page">
<webdiyer:AspNetPager ID="AspNetPager2" runat="server" CurrentPageButtonClass="current"
OnPageChanging="AspNetPager2_PageChanging" FirstPageText="首页" LastPageText="最后一页"
NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Center" ShowBoxThreshold="10"
ShowPageIndexBox="Auto" AlwaysShow="True" PageSize="9">
</webdiyer:AspNetPager>
&nbsp;`
</div>
.oa-el-grid-page a, .oa-el-grid-page input[type="submit"] {
background-color: #FFFFFF;
border-color: #EEEEEE;
border-style: solid;
border-width: 1px;
color: #036CB4;
margin: 2px;
padding: 2px 5px;
text-decoration: none;
}
.oa-el-grid-page .current {
background-color: #036CB4;
border-color: #036CB4;
border-right: 1px solid #036CB4;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
font-weight: bold;
margin: 2px;
padding: 2px 5px;
}
 public void DataLoad(int pidx)
{
string TiaoJian = " 1=1 ";
if (txtxfd.Value != "")
TiaoJian += " and name like '%" + txtxfd.Value + "%'";
AspNetPager2.RecordCount = new BLL.Sys_card_class().GetCount(TiaoJian); //分页大小、页码、排序列,升序{False}/降序(True),条件
List<Model.Sys_card_class> LRDate = new BLL.Sys_card_class().GetPageList(AspNetPager2.PageSize, pidx, "id", false, TiaoJian);
if (LRDate.Count > )
{
int i = ;
foreach (Model.Sys_card_class LR in LRDate)
{
ContentStr += "<tr>";
ContentStr += "<td width=\"200px\">" + i.ToString() + "</td>";
ContentStr += "<td width=\"310px\">" + LR.id.ToString() + "</td>";
ContentStr += "<td width=\"310px\">" + LR.name.ToString() + "</td>"; ContentStr += "<td width=\"130px\">";
ContentStr += "<a href='Card_class_Edit.aspx?addoredit=edit&id=" + LR.id.ToString() + @"'>编辑</a>";
ContentStr += "&nbsp;&nbsp;&nbsp;&nbsp;<a class=\"linkcss\" href=\"#\" onclick=\"javascript:if(confirm('确定要删除吗?')){DeleMenu('" + LR.id.ToString() + "');}\" title=\"删除\">删除</a>";
ContentStr += "&nbsp;</td>";
ContentStr += "</tr>"; i++;
}
}
} protected void AspNetPager2_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
DataLoad(e.NewPageIndex);
}

例:

/*样式一:<webdiyer:AspNetPager CssClass="oa-el-grid-page"*/

protected void AspNetPager2_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
LoadDataInfo();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
LoadDataInfo();
}

下载AspNetPager.dll

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="9" ShowPageIndexBox="Never"
CssClass="pagination" LayoutType="Ul" PagingButtonLayoutType="UnorderedList" PagingButtonSpacing="0" CurrentPageButtonClass="active" OnPageChanged="AspNetPager1_PageChanged" ShowCustomInfoSection="Never">
</webdiyer:AspNetPager>
/*分页样式*/
.liPager {
width: 100%;
background-color: #F5F5F5;
vertical-align: middle;
text-align: left;
height: 35px;
line-height: 35px;
display: inline-block;
} .liPager li, .liPager a {
font-family: 微软雅黑;
font-size: 12px;
font-weight: bold;
color: white;
text-align: center;
background-color: #1E71B1;
display: inline-block;
width: 30px;
height: 30px;
border-radius: 30px; /* 所有角都使用半径为5px的圆角,此属性为CSS3标准属性 */
-moz-border-radius: 30px; /* Mozilla浏览器的私有属性 */
-webkit-border-radius: 30px; /* Webkit浏览器的私有属性 */
border-radius: 30px 28px 26px 24px; /* 四个半径值分别是左上角、右上角、右下角和左下角 */
} /*======bootstrap风格========*/ .pagination {
display: inline-block;
padding-left:;
margin: 5px 0;
border-radius: 4px;
font-size:14px;
float: right;
} .pagination > li {
display: inline;
} .pagination > li > a, .pagination > li > span {
position: relative;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
} .pagination > li:first-child > a, .pagination > li:first-child > span {
margin-left:;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
} .pagination > li:last-child > a, .pagination > li:last-child > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
} .pagination > li > a:focus, .pagination > li > a:hover, .pagination > li > span:focus, .pagination > li > span:hover {
color: #23527c;
background-color: #eee;
border-color: #ddd;
} .pagination > .active > a, .pagination > .active > a:focus, .pagination > .active > a:hover, .pagination > .active > span, .pagination > .active > span:focus, .pagination > .active > span:hover {
z-index:;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
} .pagination > .disabled > a, .pagination > .disabled > a:focus, .pagination > .disabled > a:hover, .pagination > .disabled > span, .pagination > .disabled > span:focus, .pagination > .disabled > span:hover {
color: #777;
cursor: not-allowed;
background-color: #fff;
border-color: #ddd;
} .pagination-lg > li > a, .pagination-lg > li > span {
padding: 10px 16px;
font-size: 18px;
} .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
} .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
} .pagination-sm > li > a, .pagination-sm > li > span {
padding: 5px 10px;
font-size: 12px;
} .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span {
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
} .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
} /*分页*/
.pagination a[disabled] {
color: #777;
cursor: not-allowed;
background-color: #fff;
border-color: #ddd;
} .pagination span.active {
z-index:;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
}

例2:

 /// </summary>
/// <param name="ds">DataSet实例</param>
/// <param name="datalistname">DataList名称</param>
/// <param name="pagesize">分页大小</param>
public static string GetPageNumjxjdc(DataSet ds, DataList datalistname, int pagesize, string bc)
{
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[].DefaultView;
objPds.AllowPaging = true;
int total = ds.Tables[].Rows.Count;
objPds.PageSize = pagesize;
int page;
if (HttpContext.Current.Request.QueryString["page"] != null)
page = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"]);
else
page = ;
objPds.CurrentPageIndex = page - ;
datalistname.DataSource = objPds;
datalistname.DataBind();
int allpage = ;
int next = ;
int pre = ;
int startcount = ;
int endcount = ;
string pagestr = "";
string c = bc;
if (page < ) { page = ; }
//计算总页数
if (pagesize != )
{
allpage = (total / pagesize);
allpage = ((total % pagesize) != ? allpage + : allpage);
allpage = (allpage == ? : allpage);
}
next = page + ;
pre = page - ;
startcount = (page + ) > allpage ? allpage - : page - ;//中间页起始序号
//中间页终止序号
endcount = page < ? : page + ;
if (startcount < ) { startcount = ; } //为了避免输出的时候产生负数,设置如果小于1就从序号1开始
if (allpage < endcount) { endcount = allpage; } //页码+5的可能性就会产生最终输出序号大于总页码,那么就要将其控制在页码数之内
pagestr = "共" + allpage + "页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; pagestr += page > ? "<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=1&c=" + c + "\">首页</a>&nbsp;&nbsp;<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + pre + "&c=" + c + "\">上一页</a>" : "首页 上一页";
//中间页处理,这个增加时间复杂度,减小空间复杂度
//for (int i = startcount; i <= endcount; i++)
//{
// pagestr += page == i ? "&nbsp;&nbsp;<font color=\"#ff0000\">" + i + "</font>" : "&nbsp;&nbsp;<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + i + "&c=" + c + "&t=" + t + "\">" + i + "</a>";
//}
pagestr += page != allpage ? "&nbsp;&nbsp;<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + next + "&c=" + c + "\">下一页 </a>&nbsp;&nbsp;<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + allpage + "&c=" + c + "\">末页</a>" : " 下一页 末页"; return pagestr;
} /*
       RepeaterTeach.DataSource = ds.Tables[].DefaultView;
RepeaterTeach.DataBind();
PageInfo.InnerHtml = GetPageNumjxjdc(ds, RepeaterTeach, ,"");
*/
 <p class="jl_fy" id="PageInfo" runat="server">
</p>

分页控件-ASP.NET(AspNetPager)的更多相关文章

  1. AspNetPager分页控件配置

    AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件: 拖过来之后,设置如下属性: <webdiye ...

  2. asp.net分页控件

    一.说明 AspNetPager.dll这个分页控件主要用于asp.net webform网站,现将整理代码如下 二.代码 1.首先在测试页面Default.aspx页面添加引用 <%@ Reg ...

  3. PagedDataSource数据绑定控件和AspNetPager分页控件结合使用列表分页

    1.引用AspNetPager.dll. 2.放置Repeater数据绑定控件. <asp:Repeater ID="Repeater1" runat="serve ...

  4. Repeater + 分页控件 AspNetPager 研究

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs ...

  5. asp.net webform 自定义分页控件

    做web开发一直用到分页控件,自己也动手实现了个,使用用户自定义控件. 翻页后数据加载使用委托,将具体实现放在在使用分页控件的页面进行注册. 有图有真相,给个直观的认识: 自定义分页控件前台代码: & ...

  6. AspNetPager分页控件

    AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:1.首先到www.we ...

  7. AspNetPager 免费分页控件7.5.1版发布!

    AspNetPager 免费分页控件7.5.1版发布,本次升级主要内容有: 修正了ShowDisabledButtons为false时html闭合标签丢失的bug:改为从System.Web.UI.W ...

  8. 【转】AspNetPager分页控件用法

    AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码: 1.首先到www.w ...

  9. asp.net 分页-自己写分页控件

    去年就发表过asp.net 分页-利用后台直接生成html分页 ,那种方法只是单纯的实现了分页,基本不能使用,那时就想写个自己的分页控件,无奈能力有限.最近有点时间了,就自己做出了这个分页控件.我承认 ...

随机推荐

  1. 从走出校门到Java实习生生活

    序 男,95年,这个学期就大四了,非计算机专业(数字媒体).目前在二线城市做Java实习生,待遇一般,应该算一个正常的实习生水平吧:租的一个约10平米的小单间,实习工资-衣食住行-杂七杂八的小消费差不 ...

  2. 《android基于andFix的热修复方案》思路篇

    1:需求背景 项目上线之后,发现BUG需要修复(比如安卓兼容性等测试难以发现的问题),频繁的更新影响用户体验 2:方案要求 静默下载,耗费流量少,打完补丁后立刻生效,不用重启apk 3:解决思路 3. ...

  3. ios9+xcode7 适配笔记

    升级了xcode7,最近ios9上马,又到了草泥马的时间,apple开放团队每次系统更新,都是无数个草泥马的适配夜晚,现在ios9上线以前的app竟然启动crash,这是要闹哪样. 1.微信和微博的s ...

  4. 24.C#LINQ TO XML(十二章12.3)

    自己也写了那么多,但还有很多不懂,有点浮躁吧,但饭还是要吃啊,说说LINQ TO XML吧. LINQ TO XML位于System.Xml.Linq程序集,并且大多数类型位于System.Xml.L ...

  5. Linq之Linq to Sql

    目录 写在前面 系列文章 Linq to sql 总结 写在前面 上篇文章介绍了linq to xml的相关内容,linq to xml提供一种更便捷的创建xml树,及查询的途径.这篇文章将继续介绍l ...

  6. 使用Struts2和jQuery EasyUI实现简单CRUD系统(转载汇总)

    使用Struts2和jQuery EasyUI实现简单CRUD系统(一)——从零开始,ajax与Servlet的交互 使用Struts2和jQuery EasyUI实现简单CRUD系统(二)——aja ...

  7. Java基础-多线程

    介绍 操作系统能同时运行几个程序,每个独立运行的程序又称之为进程. 对于同一个程序,它又可以分成若干个独立的执行流,我们称之为线程.线程提供了多任务处理的能力 用进程和线程的观点来研究软件是当今普遍采 ...

  8. 【bzoj1050】 旅行comf

    http://www.lydsy.com/JudgeOnline/problem.php?id=1050 (题目链接) 题意 给出一个无向图,求图中两点间某条路径使得最大权值除以最小权值的值最小 So ...

  9. Server Data Synchronization Via Linux rsync、rsync+inotify Between Load Balance Server

    目录 . 远程文件同步的应用场景 . rsync+crontab . rsync+inotify 1. 远程文件同步的应用场景 在负载均衡集群的应用场景中,往往在多台web server的前端有一个提 ...

  10. Alpha阶段个人总结

    一. 工作总结 第一次接触通信和服务端框架,在前期准备阶段学习了很多不同的技术,也相应花费了很多时间去尝试.刚开始时还不知道框架这种东西,准备自己写,于是学习并尝试了一些简单的HTTP通信,比较麻烦, ...