.net分页控件webdiyer:AspNetPager
首先下载: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();
}

.net分页控件webdiyer:AspNetPager的更多相关文章
- 分页控件Webdiyer.MvcPager
MVC 1.安装控件 install-package Webdiyer.MvcPager 2.Cotroller using System; using System.Collections.Gene ...
- 自己动手用Javascript写一个无刷新分页控件
.NET技术交流群:337901356 ,欢迎您的加入! 对 于一个用户体验好的网站来说,无刷新技术是很重要的,无刷新,顾名思义,就是局部刷新数据,有用过Asp.net Web Form技术开发网页的 ...
- AspNetPager分页控件配置
AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件: 拖过来之后,设置如下属性: <webdiye ...
- AspNetPager分页控件
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:1.首先到www.we ...
- AspNetPager 免费分页控件7.5.1版发布!
AspNetPager 免费分页控件7.5.1版发布,本次升级主要内容有: 修正了ShowDisabledButtons为false时html闭合标签丢失的bug:改为从System.Web.UI.W ...
- 【转】AspNetPager分页控件用法
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码: 1.首先到www.w ...
- 分页控件-ASP.NET(AspNetPager)
AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件: <div class="oa-el ...
- 给AspNetPager分页控件添加bootstrap样式
AspNetPager分页控件算是比较好用的一个分页控件了.想要结合bootstrap使用,官方代码入口 .pagination a[disabled]{ color: #777;cursor: no ...
- 分页控件AspNetPager学习笔记
1.AspNetPager简介 AspNetPager是一款开源.简单易用.可定制化等等各种优点的Web分页控件. 2.使用方法 1)下载AspNetPager.dll文件(http://www.we ...
随机推荐
- [Mysql] MySQL配置文件my.cnf的理解
一.缘由 最近要接手数据库的维护工作,公司首选MySQL.对于MySQL的理解,我认为很多性能优化工作.主从主主复制都是在调整参数,来适应不同时期不同数量级的数据. 故,理解透彻my.cnf里的参数是 ...
- 使ViewStub 来提高UI的加载的性能
首先看下API中的ViewStub 根据的文档的说明,ViewStub是一种默认不可见的试图,它没有大小,所以不能被改变,也不能通过某些把viewstub添加到布局当中来, 不过我们可以使用infla ...
- Mac下Tomcat启动时乱码
#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`" 我是直接 ...
- Gerrit清单库配置(转载)
From:http://fatalove.iteye.com/blog/1340334 gerrit清单库是用来配合repo使用的.清单库中列出了gerrit服务器上的其他版本库. 客户端通过repo ...
- iOS字符串加密至MD5&及获取文件MD5
iOS 字符串加密至MD5 #import <CommonCrypto/CommonDigest.h> + (NSString *) md5:(NSString *)str { const ...
- Mysql设置字符编码及varchar宽度问题
ubuntu16.04通过仓库安装的mysql5.7的配置文件在 /etc/mysql/mysql.conf.d/mysqld.cnf 修改字符只需要 在[mysqld] character-set- ...
- JavaScript判断字符串是否含有中文(实用)
引用页: http://javasam.iteye.com/blog/1465048 UTF-8有点类似于Haffman编码,它将Unicode编码为:0x00-0x7F的字符,用单个字节来表示:0x ...
- 20. Valid Parentheses(stack)
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- MyEclipse 6.5 破解文件代码
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader; public cl ...
- UIApplication及UIWindow
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...