下面所记得东西仅仅是使用方法,详细知识点请看链接:http://www.webdiyer.com/Controls/AspNetPager/Downloads

首先:从网站上下载并安装控件

下载地址: http://www.nuget.org/packages/AspNetPager_CN/(若无法打开,直接在Nuget中输入以下命令进行安装)

PM>     Install-Package AspNetPager_CN

将控件拖进web窗体中,设置如下格式

<webdiyer:AspNetPager ID="AspNetPager1" runat="server" UrlPaging="true" AlwaysShow="true"
FirstPageText="首页" LastPageText="末页" OnPageChanged="AspNetPager1_PageChanged"
NextPageText="下一页" PrevPageText="上一页" CustomInfoHTML="目前是第%CurrentPageIndex%页 / 总共%PageCount%页"
ShowCustomInfoSection="Right" PagingButtonSpacing="0px" NumericButtonCount="5"
CssClass="anpager" CurrentPageButtonClass="cpb" Width="850px">
</webdiyer:AspNetPager>

样式如下:

后台代码

   protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeater();
}
} private void BindRepeater()
{
int currentPage = AspNetPager1.CurrentPageIndex;
int pageSize = AspNetPager1.PageSize;
int recordCount; StudentDAL dal = new StudentDAL();
DataSet ds = dal.GetPage(currentPage, pageSize, out recordCount);
AspNetPager1.RecordCount = recordCount;
string ss = AspNetPager1.CustomInfoHTML;
//AspNetPager1.CustomInfoHTML += "共" + recordCount + "条新闻"; Repeater1.DataSource = ds;
Repeater1.DataBind(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindRepeater();
}

DAL层代码

   /// <summary>
/// 得到数据页
/// </summary>
/// <param name="currentPage">当前第几页</param>
/// <param name="pageSize">每页有多少条数据</param>
/// <param name="recordCount">数据总条数</param>
/// <returns></returns>
public DataSet GetPage(int currentPage, int pageSize, out int recordCount)
{
int start=;
if(currentPage<=)
{
}
else
{
start=(currentPage-)*pageSize;
} int end=currentPage*pageSize;
string sql = "select top "+pageSize+" * from T_Student where Id not in(select top "+start+" Id from T_Student)"; //SqlParameter[] ps = {
// new SqlParameter("@takeNum",pageSize),
// new SqlParameter("@skipNum",start)
// };
recordCount = (int)SqlHelper.ExecuteScalar("select count(1) from T_Student");
return SqlHelper.ExecuteDatable(CommandType.Text, sql);
}

同样可以设置控件css样式:

CSS样式:

/*先引入bootstrap.css*/
.pagination a[disabled]{ color: #777;cursor: not-allowed;background-color: #fff;border-color: #ddd;}
.pagination span.active{z-index: 2;color: #fff;cursor: default;background-color: #337ab7;border-color: #337ab7;}

属性设置:CssClass="pagination" LayoutType="Ul" PagingButtonLayoutType="UnorderedList" PagingButtonSpacing="0" CurrentPageButtonClass="active"

网易风格:

CSS样式:

.anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}
.anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}
.anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}

属性设置:CssClass="anpager" CurrentPageButtonClass="cpb"  PagingButtonSpacing="0"

拍拍网风格:

CSS样式:

.paginator { font: 11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin: 0px;}
.paginator a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px}
.paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.paginator .cpb {padding: 1px 6px;font-weight: bold; font-size: 13px;border:none}
.paginator a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}

属性设置:CssClass="paginator" CurrentPageButtonClass="cpb" PagingButtonSpacing="0"

迅雷风格:

CSS样式:

.pages {  color: #999;overflow: auto; }
.pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}
.pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
.pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}

属性设置:CssClass="pages" CurrentPageButtonClass="cpb" PagingButtonSpacing="0"

AspNetPager分页控件的使用的更多相关文章

  1. AspNetPager分页控件

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

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

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

  3. 给AspNetPager分页控件添加bootstrap样式

    AspNetPager分页控件算是比较好用的一个分页控件了.想要结合bootstrap使用,官方代码入口 .pagination a[disabled]{ color: #777;cursor: no ...

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

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

  5. AspNetPager分页控件配置

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

  6. AspNetPager分页控件使用方法

    一.下载AspNetPager.dll 二.AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引用dll文件 三. 在工具栏中添加控件,这样可以支持拖拽使用 四. 要使用Asp ...

  7. AspNetPager分页控件的使用方法

    1. 首先将AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引入dll文件 (通过NuGet获取) 2. 在工具栏中添加控件,这样可以支持拖拽使用 3.页面拖入分页控件,设置 ...

  8. AspNetPager分页控件样式的使用

    分页是Web应用程序中最常用到的功能之一,AspNetPager  简单实用,应用到项目后台中,棒极了! 自定义样式: <style type="text/css"> ...

  9. AspNetPager分页控件官方网站

    原文发布时间为:2009-12-04 -- 来源于本人的百度文章 [由搬家工具导入] http://www.webdiyer.com/AspNetPager

随机推荐

  1. 搜索框(Thinkphp5.0)

    1.普通关键词搜索框 模板部分代码: <form name='searchform' action='/index.php/module/controller/search' method='g ...

  2. jvascript 顺序查找和二分查找法

    第一种:顺序查找法 中心思想:和数组中的值逐个比对! /* * 参数说明: * array:传入数组 * findVal:传入需要查找的数 */ function Orderseach(array,f ...

  3. 苹果iphone手机上input的button按钮颜色显示有问题,安卓却没问题

    苹果手机中会如类似上图,安卓却可以按自己写的来显示 解决办法: -webkit-appearance: none; 以上即可,当然样式中可以加上通用的: 通用:input[type=button], ...

  4. git误删文件找回方法/git版本回退方法

    使用git命令 git rm css/\*.css 我删掉了css文件夹下所有以.css结尾的文件,那么要怎样才能把文件找回来呢,下面说说方法,删掉其他的文件也是一样的方式找回. 第一步:使用git ...

  5. Datalogic组网模式下通讯

    1.首先要在visiset工具下,设置好地址端口号,组网模式master slave参数: 2.打开工具hercules,选择TCP Client选项,设置参数好连接并通讯,发送打开.关闭 按钮指令, ...

  6. Sublime Text 3 Plugin Better!

    Package Control Cmake ConvertUTF Markdown preview MarkdownEditing Marking Changed Rows

  7. JSTL标签库(一)核心标签库

    核心标签库(core) 1.表达式操作 2.流程控制 3.迭代操作 4.URL操作 1.表达式操作 标签 语法 功能 说明 <c:out> <c:out value="&l ...

  8. JS学习:第一周——NO.4继承

    1.[关于call] 作用:是用来改变this指向的,有两种参数 第一种:第一个参数,用来改变this指向 第二种:给call前面的函数传参,从第二个参数开始,给call前面的函数从左到右一个个的传参 ...

  9. 获取pe文件的文件类型

    工程文件petype.cpp通过调用pefile类中的函数获取文件类型. 文件类型的判断通过5个监测点完成. 监测点1:dos头的e_magic 监测点2:nt头的Signature 监测点3:文件头 ...

  10. 【Python网络爬虫二】使用urllib2抓去网页内容

    在Python中通过导入urllib2组件,来完成网页的抓取工作.在python3.x中被改为urllib.request. 爬取具体的过程类似于使用程序模拟IE浏览器的功能,把URL作为HTTP请求 ...