首先下载: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. unsigned char 转字符串:

    通常送显示的都是字符串,对于int long float转字符串有对应的函数,还有sprintf进行格式输出,对于嵌入式和单片机大多都用unsigned char型变量,转字符串需要自己编写函数,需要 ...

  2. RocketMQ术语[转]

    RocketMQ RocketMQ是一款分布式.队列模型的消息中间件,具有以下特点:能够保证严格的消息顺序 能够保证严格的消息顺序 提供丰富的消息拉取模式 高效的订阅者水平扩展能力 实时的消息订阅机制 ...

  3. Web性能压力测试工具之ApacheBench(ab)详解

    PS:网站性能压力测试是性能调优过程中必不可少的一环.只有让服务器处在高压情况下才能真正体现出各种设置所暴露的问题.Apache中有个自带的,名为ab的程序,可以对Apache或其它类型的服务器进行网 ...

  4. CAP原则(CAP定理)

    CAP原则又称CAP定理,指的是在一个分布式系统中, Consistency(一致性). Availability(可用性).Partition tolerance(分区容错性),三者不可得兼. CA ...

  5. 如何实现多个div水平均匀排列且量两端贴壁

    下面先看一段代码实例: <!DOCTYPE html><html><head><meta charset=" utf-8">< ...

  6. by which, in which, from which 语法区别

    (1)Here is Beijing,where I grow up.where其实也是指代北京,不过where是在北京的意思,也就是 in Beijing (2)Here is Beijing,in ...

  7. JMeter中3种参数值的传递

    小伙伴们在使用JMeter的过程中,肯定会遇到参数值传递的问题,下面来和大家总结下,在使用JMeter做压力测试的时候,常见的3种参数值的传递是怎样的. (一)从CSV文件读取要批量输入的变量 假如我 ...

  8. oracle—无法启动

    pl/sql连接oracle,出现下列错误,即没有启动该数据库的监听程序 启动该数据库的监听程序,出现如下错误,即未配置监听器 配置监听器

  9. Python 描述符(descriptor) 杂记

    转自:https://blog.tonyseek.com/post/notes-about-python-descriptor/ Python 引入的“描述符”(descriptor)语法特性真的很黄 ...

  10. Codeforces 418d Big Problems for Organizers [树形dp][倍增lca]

    题意: 给你一棵有n个节点的树,树的边权都是1. 有m次询问,每次询问输出树上所有节点离其较近结点距离的最大值. 思路: 1.首先是按照常规树形dp的思路维护一个子树节点中距离该点的最大值son_di ...