• 分页及页码导航 用户控件


    该控件成形如图:

    主要功能如下:
    用户设置每页行数 (或者不设置 则该控件默认每页10笔数据)
    用户设置分页控件的数据源DataTable(或者输入查询sql)
    该控件会先将传入的数据源保存到session(这样之后就不用重复查询)
    然后根据用户的操作(第一页、上一页,下一页,最后页,Go页)
    以及当前所在的页码
    得到符合条件的返回数据 (即点击下一页或上一页后 需要正确显示的数据集)
    同时 可以根据数据是否多于一页 来决定该控件是否需要显示
    然后用户可以选用 这返回的DataTable数据集进行相关操作
    (本控件 已加入部分js判断)
    ==============
    示例源代码如下:
    ++++++++++++++++++
    PageIndexCtl.ascx
    +++++++++++++


    +++++++++++++++++++++
    PageIndexCtl.ascx.cs
    +++++++++++++++++++++

    ++++++++++++++++++++++++
    testPageIndexCtl.aspx.cs
    ++++++++++++++++++++++++
    protected void Button1_Click(object sender, EventArgs e)
        
    {
            
    string strComm = " SELECT * From Table1 order by id aesc ";
            SqlResult sr 
    = Broker.Execute(strComm);
            DataTable dt 
    = ObjectView.GetDataView(sr).Table;

            
    this.PageIndexCtl1.CountPerPage = 5;
            GridView1.DataSource 
    = PageIndexCtl1.selfMeasure(dt);
            GridView1.DataBind();
        }


        
    protected void Page_Init()
        
    {
            
    //订阅事件
            this.PageIndexCtl1.EventFirstPage += new System.EventHandler(this.EventFirstPage);
            
    this.PageIndexCtl1.EventPrePage += new System.EventHandler(this.EventPrePage);
            
    this.PageIndexCtl1.EventNextPage += new System.EventHandler(this.EventNextPage);
            
    this.PageIndexCtl1.EventLastPage += new System.EventHandler(this.EventLastPage);
            
    this.PageIndexCtl1.EventGoPage += new System.EventHandler(this.EventGoPage);
        }


        
    private void EventFirstPage(object sender, EventArgs e)
        
    {
            
            
    this.GridView1.DataSource = this.PageIndexCtl1.dt_Result;
            
    this.GridView1.DataBind();
        }

        
    private void EventPrePage(object sender, EventArgs e)
        
    {
            
    this.GridView1.DataSource = this.PageIndexCtl1.dt_Result;
            
    this.GridView1.DataBind();
        }

        
    private void EventNextPage(object sender, EventArgs e)
        
    {
            
    this.GridView1.DataSource = this.PageIndexCtl1.dt_Result;
            
    this.GridView1.DataBind();
        }

        
    private void EventLastPage(object sender, EventArgs e)
        
    {
            
    this.GridView1.DataSource = this.PageIndexCtl1.dt_Result;
            
    this.GridView1.DataBind();
        }

        
    private void EventGoPage(object sender, EventArgs e)
        
    {
            
    this.GridView1.DataSource = this.PageIndexCtl1.dt_Result;
            
    this.GridView1.DataBind();
        }


  • 相关阅读:
    爬虫07-requests库cookie和session
    爬虫06-处理不信任的SSL证书
    爬虫05-requests库用法
    爬虫04-cookie
    网络爬虫-爬取拉勾网不成功,登录设置cookie
    爬虫03-简单使用代理
    爬虫02-简单伪装浏览器
    爬虫01-urllib常用函数
    01-matplotlib简单绘图
    21-pandas_apply和transform
  • 原文地址:https://www.cnblogs.com/freeliver54/p/607331.html
Copyright © 2020-2023  润新知