<webdiyer:AspNetPager ID="pager" runat="server" class="page" FirstPageText="首页" LastPageText="尾页" PageIndexBoxType="DropDownList"
                    NextPageText="后页" PageSize="20" PrevPageText="前页" ShowPageIndexBox="Always" TextAfterPageIndexBox="页"
                    TextBeforePageIndexBox="跳转到: " Width="100%" PagingButtonType="Image" ImagePath="/SysManager/images/"
                    NumericButtonType="Text" ButtonImageExtension=".jpg" CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条 共 %RecordCount% 条数据"
                    ShowCustomInfoSection="Right" AlwaysShow="True" MoreButtonType="Text"  OnPageChanged="Pager_PageChanged" >
                </webdiyer:AspNetPager>

<%--                <webdiyer:AspNetPager ID="pager" runat="server" class="page" EnableTheming="true"
                    FirstPageText="首页" LastPageText="尾页" NextPageText="后页" OnPageChanged="Pager_PageChanged"
                    PageIndexBoxType="DropDownList" PageSize="2" PrevPageText="前页" ShowPageIndexBox="Always"
                    TextAfterPageIndexBox="页" TextBeforePageIndexBox="跳转到: " Width="100%" NumericButtonType="Text"
                    CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条 共%RecordCount%条数据" ShowCustomInfoSection="Right"
                    AlwaysShow="True">
                </webdiyer:AspNetPager>--%>

以下是一个完整的示例:
<webdiyer:aspnetpager id="AspNetPager1" runat="server" 
       alwaysshow="True"
       PageSize="5" 
       custominfosectionwidth="20%" 
       custominfotextalign="Right" 
       firstpagetext="第一页"
       horizontalalign="Left" 
       lastpagetext="末一页" 
       navigationbuttontype="Image"  
       nextpagetext="后一页"
       pageindexboxtype="TextBox"
       pagingbuttonspacing="8px"
       prevpagetext="前一页" 
       showcustominfosection="Right" 
       showpageindexbox="Always" 
       textafterpageindexbox="页" 
       UrlPaging="true" 
       textbeforepageindexbox="跳到第"
       width="97%" 
       onpagechanged="AspNetPager1_PageChanged">
</webdiyer:aspnetpager>
alwaysshow:总是显示分页控件;
PageSize:指定每页显示的记录数;
custominfosectionwidth:用户自定义信息区的宽度;
custominfotextalign:用户自定义信息区的对齐方式;
firstpagetext:第一页按钮上显示的文本;
horizontalalign:内容水平对齐方式;
lastpagetext:最后页按钮上显示的文本;
navigationbuttontype:第一页、下一页、最后一页按钮的类型;
nextpagetext:下一页按钮上显示的文本;
pageindexboxtype:指示页索引框的显示类型:有TextBOX和dropdownlist两种;
pagingbuttonspacing:导航页按钮的间距;
prevpagetext:上一页按钮的显示的文本;
showcustominfosection:显示当前页和总页信息,默认为不显示,值为LEFT时将显示在页索引前,为right时显示在页索引后;
showpageindexbox:指定页索引文本框或下拉框的显示方式;
textafterpageindexbox:指定页索引文本框或下拉框后的文本;
UrlPaging:是够使用URL传递分页的方式来分页;
textbeforepageindexbox:指定页索引文本框或下拉框前面显示的文本;
width:该控件的宽度;
CustomInfoHTML:指定要显示在用户自定义信息区的用户自定义HTML信息文本
   
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Bind();
    }
    private void Bind()
    {
        int pageindex = 1;
        int pagenum = AspNetPager1.PageSize;
        if (Request["page"] != null)
        {
            pageindex =Convert.ToInt32(Request["page"]);
        }
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString ());
        SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
        SqlDataAdapter sda = new SqlDataAdapter("select top (@pagenum) * from pagetest where id not in (select top  (@pagenum*(@pageindex-1)) id from pagetest)", con);
        sda.SelectCommand.Parameters.AddWithValue("pagenum",pagenum);
        sda.SelectCommand.Parameters.AddWithValue("pageindex",pageindex);
        sda.Fill(ds);
        SqlCommand cmd = new SqlCommand("select count(*) from pagetest", con1);
        con1.Open();
        AspNetPager1.RecordCount =Convert.ToInt32(cmd.ExecuteScalar());
        con.Close();
        AspNetPager1.CustomInfoHTML = "共" + AspNetPager1.RecordCount + "条记录      " + AspNetPager1.CurrentPageIndex + "/" + AspNetPager1.PageCount;
        GridView1.DataSource = ds.Tables[0].DefaultView;
        GridView1.DataBind();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        Bind();
    }
}
深入分析CurrentPageIndex、RecordCount、 PageCount、 PageSize:
  
pagecount:
  
public int PageCount
{
    get
    {
        if (this.RecordCount == 0)
        {
            return 1;
        }
        return (int) Math.Ceiling((double) (((double) this.RecordCount) / ((double) this.PageSize)));
    }
}
recordcount:
  
public int RecordCount
{
    get
    {
        if (this.cloneFrom != null)
        {
            return this.cloneFrom.RecordCount;
        }
        object obj2 = this.ViewState["Recordcount"];
        if (obj2 != null)
        {
            return (int) obj2;
        }
        return 0;
    }
    set
    {
        this.ViewState["Recordcount"] = value;
    }
}
CurrentPageIndex:
  
public int CurrentPageIndex
{
    get
    {
        if (this.cloneFrom != null)
        {
            return this.cloneFrom.CurrentPageIndex;
        }
        object obj2 = this.ViewState["CurrentPageIndex"];
        int num = (obj2 == null) ? 1 : ((int) obj2);
        if ((num > this.PageCount) && (this.PageCount > 0))
        {
            return this.PageCount;
        }
        if (num < 1)
        {
            return 1;
        }
        return num;
    }
    set
    {
        int pageCount = value;
        if (pageCount < 1)
        {
            pageCount = 1;
        }
        else if (pageCount > this.PageCount)
        {
            pageCount = this.PageCount;
        }
        this.ViewState["CurrentPageIndex"] = pageCount;
    }
}
PageSize:
  
public int PageSize
{
    get
    {
        int num;
        if ((!string.IsNullOrEmpty(this.UrlPageSizeName) && !base.DesignMode) && (int.TryParse(this.Page.Request.QueryString[this.UrlPageSizeName], out num) && (num > 0)))
        {
            return num;
        }
        if (this.cloneFrom != null)
        {
            return this.cloneFrom.PageSize;
        }
        object obj2 = this.ViewState["PageSize"];
        if (obj2 != null)
        {
            return (int) obj2;
        }
        return 10;
    }
    set
    {
        this.ViewState["PageSize"] = value;
    }
}

ASPNETPager常用属性相关推荐

  1. selenium提取数据之driver对象的常用属性和方法

    selenium提取数据之driver对象的常用属性和方法 在使用selenium过程中,实例化driver对象后,driver对象有一些常用的属性和方法 driver.page_source 当前标 ...

  2. 尚硅谷学习笔记-节点的常用属性和方法

    节点的常用属性和方法[图片在末尾] 方法: 通过具体的元素节点调用 getElementsByTagName() 方法,获取当前节点的指定标签名孩子节点 appendChild( oChildNode ...

  3. Node.js process 模块常用属性和方法

    Node.js是常用的Javascript运行环境,本文和大家发分享的主要是Node.js中process 模块的常用属性和方法,希望通过本文的分享,对大家学习Node.js http://www.m ...

  4. css规则中区块block,css常用属性总结:背景background下篇

    前言:这段时间天天加班到10:30之后,简直是x了. 在上一篇文章中,分别解析了background各个属性的用法和注意细节.如果我们在项目上使用背景效果,如果使用下面的写法,你可能抓狂. body{ ...

  5. 5中div标签有没有url属性_[网页编程]-03 CSS 常用属性

    字体处理常用属性 <!DOCTYPE html> <html><head><meta charset="utf-8"><tit ...

  6. js如何操作表格(常用属性方法汇总)

    js如何操作表格(常用属性方法汇总) 一.总结 一句话总结: 二.表格相关的属性和方法 1.1 Table 对象集合 cells[] 返回包含表格中所有单元格的一个数组. 语法:tableObject ...

  7. wpf- DataGrid 常用属性和事件

    组件所在命名空间: System.Windows.Controls 组件常用方法: BeginEdit:使DataGrid进入编辑状态. CancelEdit:取消DataGrid的编辑状态. Col ...

  8. TeeChart for .NET常用属性总结

    2019独角兽企业重金招聘Python工程师标准>>> 本文总结了图表控件Teechart for .NET常用的一些属性,对图表开发人员来说是一个很好的参考. 实现绘图步骤: 1. ...

  9. js基础-字符串常用属性合集

    /*   *   * 实例方法---->必须要通过new的方式创建的对象(实例对象)来调用的方法   * 静态方法---->直接通过大写的构造函数的名字调用的方法(直接通过大写的对象名字调 ...

最新文章

  1. ALEIDoc EDI(7)--IDoc Extension
  2. 从上往下打印出二叉树的每个节点,同层节点从左至右打印
  3. Linux系统编程——线程(1)
  4. 利用Python查看微信共同好友
  5. 机器学习解决什么问题_机器学习帮助解决水危机
  6. 【免费】某机构最新3980元机器学习/大数据课程高速下载,限量200份
  7. leetcode python3 简单题26. Remove Duplicates from Sorted Array
  8. linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案
  9. VS2010-MFC(菜单:VS2010菜单资源详解)
  10. python手写lfw数据集转pair.txt形式
  11. python公开直播课_今晚Python与人工智能直播课来袭,Mars喊你快上车
  12. linux的tar命令的exclude,mac 的tar命令--exclude和linux的tar命令--exclude的区别
  13. 双11购书大优惠!独家优惠券,折后再减,赶紧来抢啊!
  14. 软件构造设计模式III(转载整合)
  15. mysql如何查询前几天_sql语句查询mysql怎么取前几天的数据
  16. 自媒体:公众号内容可以同步到头条吗
  17. 小白算法练习 lanqiao2017 国赛 发现环 tarjan 无向图
  18. 什么表示计算机存储信息的能力以字节为单位,大学计算机基础考试判断.doc
  19. 论文解读:学习蛋白质的空间结构可以提高蛋白质相互作用的预测
  20. 计算机重启恢复到推荐分辨率,电脑重启后分辨率变低?Win10分辨率调整

热门文章

  1. 如何修改ECShop发货单查询显示个数
  2. PHP的SPFA,由于是之前的c代码,风格你懂的........(夹带php队列实现)
  3. Gridview 手动排序实现
  4. 职场警示录:怎样和“小人”和睦相处
  5. 如何做好Serv-U安全设置,保护FTP服务器安全
  6. POJ 3687 Labeling Balls
  7. 生物-脑-脑容量:脑容量
  8. decode函数的使用
  9. python 垃圾回收
  10. HackerRank Nimble Game