AspNetPage分页控件的应用实现教程

作者:袖梨 2022-06-25

告白没有永恒的成功。 一、绑定办法
private void DataBindDataTable(string whereCondition) { //whereCondition是查询的前提
        IList list = SrTakeNameListManage.GetSrTabkeNameAllList(whereCondition);
        AspNetPager1.RecordCount = list.Count;//设置总条数

 代码如下 复制代码

人生最苦痛的是梦醒了无路可走。做梦的人是幸福的;倘没有看出可走的路,最要紧的是不要去惊醒他。       

 代码如下 复制代码
PagedDataSource pds = new PagedDataSource();
        pds.DataSource = list;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//当前页的索引
        pds.PageSize = AspNetPager1.PageSize;//每页显示的记录数
        GridView1.DataSource = pds;
        GridView1.DataBind();
    }

二、页面初次加载

 代码如下 复制代码
       if(!IsPostBack){
           ViewState["vkey"]=" 1=1 ";//查询前提的关键字
           DataBindDataTable(ViewState["vkey"].ToString());
        }

三、AspNetPage事务

 代码如下 复制代码
   protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        DataBindDataTable(ViewState["vkey"].ToString());
    }

四、搜刮按钮单击事务

 代码如下 复制代码
    protected void btnAllSearch_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        ViewState["vkey"] = " 1=1 ";
        DataBindDataTable(ViewState["vkey"].ToString());
    }

  

网易风格:

 代码如下 复制代码
        FirstPageText="首页" LastPageText="尾页" NextPageText="后页" PrevPageText="前页">
   

/*网易风格*/

 代码如下 复制代码
.anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}
.anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}
.anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}

拍拍网风格:

 代码如下 复制代码
            FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页">

/*拍拍网风格*/

 代码如下 复制代码
.paginator { font: 11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin: 0px;}
.paginator a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px}
.paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.paginator .cpb {padding: 1px 6px;font-weight: bold; font-size: 13px;border:none}
.paginator a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}

迅雷风格:

 代码如下 复制代码
            FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页">
   

/*迅雷风格*/

 代码如下 复制代码
.pages { color: #999 }
.pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}
.pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
.pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}
.code{font-weight:bold;color:blue}

相关文章

精彩推荐