<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. fcntl()功能 详解

    fcntl()函数可以改变已打开文件的性质 <pre lang="c" escaped="true"> #include <unistd.h& ...

  2. 【转】Eclipse常用快捷键

    原文网址:http://denver.blog.51cto.com/272871/52219 编辑相关快捷键 1.[Alt+/] 为用户提供内容的辅助. 2.[Ctrl+O] 显示类中方法和属性的大纲 ...

  3. c排序算法大全

    排序算法是一种基本并且常用的算法.由于实际工作中处理的数量巨大,所以排序算法 对算法本身的速度要求很高. 而一般我们所谓的算法的性能主要是指算法的复杂度,一般用O方法来表示.在后面将给出详细的说明.& ...

  4. 嵌入式 hi3518平台增加路由代码

    <span style="font-family:Courier New;"> /********************************** (C) COPY ...

  5. js实现密码加密

    http://www.cnblogs.com/mofish/archive/2012/02/25/2367858.html 1.base64加密 在页面中引入base64.js文件,调用方法为: &l ...

  6. js内置对象-Date对象

    Date对象: Data对象可以储存任意一个日期,并且可以精确到毫秒数(1/1000 秒). 定义: //默认初始值定义: var dataName=new Date(); /*使用关键字new;Da ...

  7. Asp.net 身份验证方式?

    [Forms 身份验证] 通过其可将没有通过身份验证的请求重定向到使用 HTTP 客户端重定向的 HTML 窗体的系统.用户提供凭据并提交该窗体.如果应用程序验证该请求,系统就会发出包含凭据或密钥的 ...

  8. C# 对Excel文档打印时的页面设置

    1.对打印页面的朝向,页宽,页高进行设置 参考源码[1] using Excel = Microsoft.Office.Interop.Excel; Excel.Application tmpExce ...

  9. IOS-多视图控制器之间的切换

    1. 创建个单视图应用程序 2. 在向Main.storyboard中拖一个ViewController控制器 3. 在第一个viewController中添加一个按钮 4. 按着control键,推 ...

  10. Protocol Buffer详解

    1.Protocol Buffer 概念 Google Protocol Buffer( 简称 Protobuf) 是 Google 公司内部的混合语言数据标准,目前已经正在使用的有超过 48,162 ...