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. 成都普华永道税务开发的offer

    首先这是一个.net税务开发的offer,我是做开发的. 有没有人在成都普华永道的,最近收到普华永道的offer,如果有的话请联系我.想知道里面的情况.最想知道里面的加班情况,薪资还是有点诱惑的.毕竟 ...

  2. OpenStack Newton:集虚拟化,裸金属和容器部署的统一云平台(转载)

    2016-10-08木屐大数据在线 国庆长假第六天,OpenStack第十四版本Newton(牛顿?)发布,官方介绍中强调这是一个集虚拟化.裸金属和容器技术的一体化平台,可通过一套API来管理裸金属. ...

  3. 每天一个linux命令(34):kill命令

    Linux 中的kill命令用来终止指定的进程(terminate a process)的运行,是Linux下进程管理的常用命令.通常,终止一个前台进程可以 使用Ctrl+C键,但是,对于一个后台进程 ...

  4. 软工实践个人练习-使用github进行代码管理

    1.掌握使用Git进行代码版本,使用github进行代码托管. 2.创建小组Organization,并邀请组员进来. 3.将代码库https://github.com/sefzu2015/AutoC ...

  5. git for windows 入门随笔

    引言: Git 是当前最流行的集中化的版本控制程序之一(版本控制是一种记录若干文件内容变化,以便将来查阅特定版本修订情况的系统),Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件 ...

  6. java设计优化-享元模式

    享元模式是设计模式中少数几个以调高系统性能为目的的设计模式.它的核心思想是:如果在一个系统中存在多个相同的对象,那么只需共享一份对象的拷贝,而不必为每一次使用都创建新的对象.在享元模式中,由于需要构建 ...

  7. 传智168期JavaEE就业班 day03-js

    * 课程回顾: * CSS * CSS的简介 * 层叠样式表. * CSS与HTML的结合(4种) * HTML的标签提供了属性 style="CSS的代码" * HTML提供了标 ...

  8. nginx配置反向代理示例

    环境: nginx1:192.168.68.41 tomcat1:192.168.68.43 tomcat2:192.168.68.45 nginx安装网上很多教程,我是用yum安装的. 配置ngin ...

  9. unicode和gbk的互相转换

    unicode和gbk的互相转换主要依靠window下的escape和unescape方法,然后把%u替换成\u就好了; var GB2312UnicodeConverter = { ToUnicod ...

  10. knockout——官网demo

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...