首先下载: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. [物理学与PDEs]第4章 反应流体力学

    [物理学与PDEs]第4章第1节 引言 [物理学与PDEs]第4章第2节 反应流体力学方程组 2.1 粘性热传导反应流体力学方程组 [物理学与PDEs]第4章第2节 反应流体力学方程组 2.2 反应流 ...

  2. C++程序设计原理与实践

    std_lib_facilities.h和VS下创建C++程序方法:下载 目录: 001. Hello,World!

  3. Redis优化经验

    内存管理优化 Redis Hash是value内部为一个HashMap,如果该Map的成员数比较少,则会采用类似一维线性的紧凑格式来存储该Map, 即省去了大量指针的内存开销,这个参数控制对应在red ...

  4. Java多线程之线程结束清理

    该事例说明了清理工作必须要放在finally块中 package Thread.Interrupting; import java.util.concurrent.TimeUnit; class Ne ...

  5. 多窗体之间方法调用 z

    C# Code: /// <summary> /// 主窗体接口 /// </summary> public interface IMdiParent{   void Pare ...

  6. 30岁IT男连续工作一个月 突然失聪

    连续开发软件一个月,30 岁男子突然听不见声音了.近日,浙江省中山医院针灸科主任高宏主任中医师接诊了这名患者.高主任说,现在很多年轻人工作压力大,得突发性耳聋的越来越多,这种病听着不是威胁生命的大病, ...

  7. [Flex] Accordion系列 - Header图标的设置

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何通过getHeaderAt()函数以及se ...

  8. Ext 4.2以后版本 ComboBox 联动

    //combox树 ComboTree: function (upDep, empStore) { var com = Ext.create('Ext.ux.desktop.ComboTree', { ...

  9. GridControl 继承写法修改自己的GridControl

    namespace GridControlDemo { class MyGridControl : GridControl { protected override BaseView CreateDe ...

  10. nyoj 76 超级台阶

    点击打开链接 超级台阶 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法? 注:规 ...