首先下载:AspNetPager.dll   AspNetPager.xml  放到bin目录下

页面添加<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

1 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged"
2 FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" ShowPageIndexBox="Never"
3 AlwaysShow="true" UrlPaging="True" ReverseUrlPageIndex="True">
4 </webdiyer:AspNetPager>

cs代码中:

 1 DataTable dt = new DataTable();
2 PagedDataSource pds = new PagedDataSource();
3
4 protected void Page_Load(object sender, EventArgs e)
5 {
6 dt = .......;
7 pds.DataSource = dt.DefaultView;
8 pds.AllowPaging = true;
9 pds.PageSize = 10;
10 AspNetPager1.RecordCount = pds.Count;
11 AspNetPager1.PageSize = pds.PageSize;
12 if (!IsPostBack)
13 {
14 Repeater1.DataSource = pds;
15 Repeater1.DataBind();
16 }
17 }
18 }
19
20 protected void AspNetPager1_PageChanged(object sender, EventArgs e)
21 {
22 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//索引同步
23 Repeater1.DataSource = pds;//数据绑定
24 Repeater1.DataBind();
25 }

这样分页显示没问题了,但要是页面中有检索条件,需要重新给datatable赋值的话,点翻页就会出问题了。比如检索出的数据有5页,而page_load中加载的datatable有10页。

点击检索按钮检索出需要的数据后,再翻页又变成全部数据了。下边解决。

DataTable dt = new DataTable();
PagedDataSource pds = new PagedDataSource();
static DataView view = new DataView();
protected void Page_Load(object sender, EventArgs e)
{
dt = .....;
if (Request.QueryString["page"] == null)
{
view = dt.DefaultView;
}
if (!IsPostBack)
{
pds.DataSource = view;
AspNetPager1.RecordCount = view.Count;
pds.AllowPaging = true;
pds.PageSize = 5;
AspNetPager1.PageSize = pds.PageSize;
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//索引同步
Repeater1.DataSource = pds;//数据绑定
Repeater1.DataBind();
}
//按条件检索
protected void Button1_Click(object sender, EventArgs e)
{
//button1 根据订单编号和订单时间搜索
string ddh = TextBox1.Text.Replace(" ", "");
string startDt = TxtStartTime.Value;
string endDt = TxtEndTime.Value;
dt = 新table;
view = dt.DefaultView;
pds.DataSource = view;
AspNetPager1.RecordCount = view.Count;
pds.AllowPaging = true;
pds.PageSize = 5;
AspNetPager1.PageSize = pds.PageSize;
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
 
 
转自:http://www.cnblogs.com/iammrwu/archive/2011/12/02/2272017.html

.net分页控件webdiyer:AspNetPager的更多相关文章

  1. 分页控件Webdiyer.MvcPager

    MVC 1.安装控件 install-package Webdiyer.MvcPager 2.Cotroller using System; using System.Collections.Gene ...

  2. 自己动手用Javascript写一个无刷新分页控件

    .NET技术交流群:337901356 ,欢迎您的加入! 对 于一个用户体验好的网站来说,无刷新技术是很重要的,无刷新,顾名思义,就是局部刷新数据,有用过Asp.net Web Form技术开发网页的 ...

  3. AspNetPager分页控件配置

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

  4. AspNetPager分页控件

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

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

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

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

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

  7. 分页控件-ASP.NET(AspNetPager)

    AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件: <div class="oa-el ...

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

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

  9. 分页控件AspNetPager学习笔记

    1.AspNetPager简介 AspNetPager是一款开源.简单易用.可定制化等等各种优点的Web分页控件. 2.使用方法 1)下载AspNetPager.dll文件(http://www.we ...

随机推荐

  1. 转-ViewPager组件(仿微信引导界面)

    http://www.cnblogs.com/lichenwei/p/3970053.html 这2天事情比较多,都没时间更新博客,趁周末,继续继续~ 今天来讲个比较新潮的组件——ViewPager ...

  2. Java中的hashCode 方法

    http://www.cnblogs.com/dolphin0520/p/3681042.html

  3. Input gameobject vector3 c#

    Input类中的常用方法 bool w=Input.GetKey(KeyCode.W);//检测是否按下键盘W Input.GetKeyDown(KeyCode.W);//表示检测按下时 Input. ...

  4. PHP框架 Laravel Eloquent ORM 批量插入数据 && 批量更新目前没有

    foreach ($products as $v=>$a) { $count[] = array('product_name' => $a['name'], 'product_weight ...

  5. WCF Windows Service Using TopShelf and ServiceModelEx z

    http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are ...

  6. ubuntu vnc install

    windows & ubuntu http://www.jb51.net/os/Ubuntu/104948.html ubuntu & ubuntu https://www.digit ...

  7. [经验总结]利用xlstproc处理XSLT的makefile

    转自:http://blog.csdn.net/thinkhy/article/details/5343739 # For XSLT PARSE = xsltproc SRC = main.xml S ...

  8. 认识与学习BASH(中)

    1.在设置变量中:单引号与双引号的最大不同:双引号能保有变量的内容,单引号仅能是一般字符 2.反单引号(`)作用:在一串指令中,在‘之内的指令将会被先执行,其结果将作为外部的输入信息. locate指 ...

  9. angularJs编写多指令的情况

    本实例主要展示controller和link参数的使用.以及多个指令同时作用的情况. <!DOCTYPE html> <html ng-app="myModule" ...

  10. DataRow对象的行状态(RowState)和行版本(DataRowVersion)属性

    DataRow对象有两个比较重要的属性,分别是行状态(RowState)和行版本(DataRowVersion),通过这两个属性能够有效的管理表中的行.下面简要的介绍一下行状态和行版本的特点和关系. ...