<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. ASPNETPager常用属性(近来用到分页属性)

    ASPNETPager常用属性 建议去封装好,然后调用这样比较容易 <webdiyer:aspnetpager id="AspNetPager1" runat="s ...

  2. AspNetPager常用属性及一些样式(本文摘自网络,作者:x123jing)

    AlwaysShow 总是显示分页控件,即使要分页的数据只有一页 AlwaysShowFirsLastPageNumbr 是否总是显示第一页和最后一页数字页索引按钮 BackImageUrl 面板的背 ...

  3. AspNetPager常用属性及一些样式

    AlwaysShow 总是显示分页控件,即使要分页的数据只有一页 AlwaysShowFirsLastPageNumbr 是否总是显示第一页和最后一页数字页索引按钮 BackImageUrl 面板的背 ...

  4. 【Android自学日记】五大布局常用属性

    线性布局(LinearLayout)常用属性: android:orientation="vertical"--决定子类控件的排布方式(vertical垂直:horizontal水 ...

  5. DataGrid中的常用属性

    DataGrid中的常用属性 $('#dg').datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',w ...

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

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

  7. ImageView的常用属性

    ImageView的一些常用属性,并且这些属性都有与之对应的getter.setter方法: android:adjustViewBounds:设置ImageView是否调整自己的边界来保持所显示图片 ...

  8. HTML a标签、4个伪类、常用属性(下载)、锚链接(待扩展:邮件、电话、短信、GPS)

    HTML 超链接<a> 1.超链接可以是一个字.一个词.一组词.一幅图像,您可以点击这些内容来跳转到新的文档或者当前文档中的某个部分. 2.当您把鼠标指针移动到网页中的某个链接上时,箭头会 ...

  9. iOS导航控制器常用函数与navigationBar常用属性

    导航控制器常用函数触发时机 当视图控制器的View将要出现时触发 - (void)viewWillAppear:(BOOL)animated 当视图控制器的View已经出现时触发 - (void)vi ...

随机推荐

  1. 国外代理server

    这里有几个国外的代理server 另外在网上能够找到很多这种 不能用的时候就在网上搜搜 稳定代理server 有非常多的 IP port 显示地址 24.245.58.130:32167 美国 新泽西 ...

  2. Sails.js中文文档

    Sails.js中文文档   http://sailsdoc.swift.ren/ Sails.js是一个Web框架,可以于轻松构建自定义,企业级Node.js Apps.它在设计上类似于像Ruby ...

  3. (转)mvn clean install 与 mvn install 的区别(为啥用clean)

    之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是 ...

  4. PHPSingleton模式的例子

    在这篇文章中PHPSingleton模式的解释不一定好!仅举它的一个例子.其目的是为了让自己通过一个例子来加深对Singleton模式的理解!这里,以供参考! 单例:能够简单的理解是通过一个类,仅仅能 ...

  5. Linux平台下裸设备的绑定:

    Linux平台下裸设备的绑定: 运用RAW绑定 方法一 raw的配置(1) [root@qs-dmm-rh2 mapper]# cat /etc/rc.local #!/bin/sh # # This ...

  6. Android - 数据存储 -存储文件

    Android使用的文件系统和其他平台的基本磁盘的文件系统很相似.这里将要介绍如何使用File API在Android文件系统中读写文件. File对象适合按顺序读写大量的数据.例如,适合图片文件或者 ...

  7. 什么时候PHP经验MySQL存储过程

    1.MySQL存储过程 数据库语言,我们经常使用的操作SQL语句必须首先编译在运行时.然后运行,存储过程(Stored Procedure)它被设置为完成一个特定的功能SQL报表设置.编译存储在数据库 ...

  8. 十天学会php第五天

    学习目标:学会读取数据    先看两个函数:    1.mysql_query    送出一个 query 字符串. 语法   : int mysql_query(string query, int ...

  9. Hibernate在关于一对多,多对一双向关联映射

    [Hibernate]之关于一对多,多对一双向关联映射 因为一对多.和多对一的双向关联映射基本上一样,所以这里就一起写下来! Annotations配置 @Entity @Table(name=&qu ...

  10. 人活系列Streetlights (秩)

    人活着系列之Streetlights Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 人活着假设是为了家庭,亲情----能够说是在这个世界上最温暖人心的, ...