<webdiyer:AspNetPager ID="AspNetPager1" UrlPaging="True" PageSize="20" runat="server" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PagingButtonSpacing="" PrevPageText="上一页" ></webdiyer:AspNetPager>

方法1.

if (!this.IsPostBack)

{

int CurrentPageIndex = AspNetPager1.CurrentPageIndex;
if (Request["page"] != null) { CurrentPageIndex = int.Parse(Request["page"]); }
BindData(CurrentPageIndex);

}

void BindData(int CurrentPageIndex)

{

datatable dt=....................;

PagedDataSource pds = new PagedDataSource();

AspNetPager1.RecordCount = dt.Rows.Count;

pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = CurrentPageIndex;
pds.DataSource = dt.DefaultView;
this.rpMsgList.DataSource = pds; //可以绑定到Gridview 、datalist等数据控件上
this.rpMsgList.DataBind();

}

不需要写分页事件代码,因为UrlPaging="True",使用了URL分页 &page=1之类的

方法2.存储过程分页

if (!this.IsPostBack)

{

int CurrentPageIndex = AspNetPager1.CurrentPageIndex;
if (Request["page"] != null) { CurrentPageIndex = int.Parse(Request["page"]); }
BindData(CurrentPageIndex);

}

void BindData(int CurrentPageIndex)
{
int pageCount = 0;
int Counts = 0;//总记录数
rpList.DataSource = SqlHelper.PageProcedure("Company,UserInfo,City,County", " UserName ,CompanyName,SName,CityName,CountyName,Contact,CompanyTypeId,Company.addtime as CompanyAddtime,Status,UId", AspNetPager1.PageSize, CurrentPageIndex, 0, " Company.Status asc, Company.addtime ", 1, " where Company.CityId=City.CityId and City.isshow=1 and Company.CountyId=County.CountyId and County.isshow=1 and Company.UId=UserInfoId " + WebComm.StrWhereHelper.Get_Admin_Company_StrWhere(), "CompanyId", ref pageCount, ref Counts);
AspNetPager1.RecordCount = Counts;
AspNetPager1.CurrentPageIndex = CurrentPageIndex;
rpList.DataBind();
}

不需要写分页事件代码,因为UrlPaging="True",使用了URL分页 &page=1之类的

aspnetpager的2种分页方法的更多相关文章

  1. phalcon几种分页方法

    phalcon几种分页方法 一: use Phalcon\Paginator\Adapter\Model as PaginatorModel; // Current page to show // I ...

  2. PostgreSQL两种分页方法查询时间比较

    数据库中存了3000W条数据,两种分页查询测试时间 第一种 SELECT * FROM test_table WHERE i_id> limit 100; Time: 0.016s 第二种 SE ...

  3. java oracle的2种分页方法

    java oracle的2种分页方法 一物理分页: <!-- 分页查询所有的博客信息 --> <select id="findBlogs" resultType= ...

  4. sql server两种分页方法

    方法一: --分页方法一 OrderID,CustomerID, EmployeeID,OrderDate,ShippedDate,ShipName,ShipAddress,Freight from ...

  5. MVC三种分页方法

    View部分: @using WebApplication1.Models;分页方法1引包 @*@using PagedList.Mvc; @using WebApplication1.Models; ...

  6. 数据分页 THINKPHP3.2 分页 三种分页方法

    数据分页 复制本页链接 opensns 通常在数据查询后都会对数据集进行分页操作,ThinkPHP也提供了分页类来对数据分页提供支持. 下面是数据分页的两种示例. 第一种:利用Page类和limit方 ...

  7. Sql三种分页方法

    --分页三种方法--第一种 ROW_NUMBER() OVER( ORDER BY OrgID) AS indexs 大于pagesize*pageindex,少于等于pagesize*(pagein ...

  8. sqlalchemy和flask-sqlalchemy的几种分页方法

    sqlalchemy中使用query查询,而flask-sqlalchemy中使用basequery查询,他们是子类与父类的关系 假设 page_index=1,page_size=10:所有分页查询 ...

  9. sqlserver两种分页方法比较

    -- 3000 page(从1开始) 10 pagesize -- 方法1(效率不高): SELECT TOP 10 * FROM [xxx].[oooo] WHERE id NOT IN (SELE ...

随机推荐

  1. phonegap 百度云推

    1 创建新工程 -----获取api key 和secret key 2,推送设置 3,新建安卓项目,并把应用包名 和 推送中设置的包名设置一致 4,下载百度云客户端sdk 5,解压,并添加libs文 ...

  2. MVC中如何跳过对模型中某个属性的验证

    [HttpPost] public ActionResult Create(Users user) { ModelState.Remove(“Password”); //加上这句就行了 if (Mod ...

  3. 【转】IPC-消息队列

    一.    概念 消息队列就是一个消息的链表.对消息队列有写权限的进程可以向其中按照一定的规则添加新消息:对消息队列有读权限的进程可以从消息队列中读出消息.消息队列是随内核持续的.下面介绍三个概念: ...

  4. WPF的控件Binding的ElementName/RelativeSource具体用法

    <TextBlock Name="_txtSickBedNo" FontStyle="Normal" Foreground="Black&quo ...

  5. Ajax轮询以及Comet模式—写在Servlet 3.0发布之前(转)

    2008 年的夏天,偶然在网上闲逛的时候发现了 Comet 技术,人云亦云间,姑且认为它是由 Dojo 的 Alex Russell 在 2006 年提出.在阅读了大量的资料后,萌发出写篇 blog ...

  6. hdu 1541 Stars(树状数组)

    题意:求坐标0到x间的点的个数 思路:树状数组,主要是转化,根据题意的输入顺序,保证了等级的升序,可以直接求出和即当前等级的点的个数,然后在把这个点加入即可. 注意:树状数组下标从1开始(下标为0的话 ...

  7. MapReduce 中job.setJarByClass()方法的疑惑

    在调试mr实例的时候,遇到如下的情况,如图所示 说明:就是我的mr程序类名称和我设置的setJarByclass()中设置的不一样,但是程序竟然没有报错!!!!当时把我吓尿了 疑惑:如果这样设置的话, ...

  8. nagios监控远程主机服务可能出现的问题

    1.使用插件NRPE监控命令不存在 在添加服务的时候,命令配置文件中需要传递一个参数,那么在监控服务配置文件中,需要添加一个!表示后面的为参数. 出现未定义的命令,查看被监控主机上的配置文件,添加监控 ...

  9. 【LeetCode】226 - Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9          to 4 / \ 7 2 / \ / \ 9 6 3 1   Notice: Goog ...

  10. Pregel: A System for Large-Scale Graph Processing(译)

    [说明:Pregel这篇是发表在2010年的SIGMOD上,Pregel这个名称是为了纪念欧拉,在他提出的格尼斯堡七桥问题中,那些桥所在的河就叫Pregel.最初是为了解决PageRank计算问题,由 ...