zoukankan      html  css  js  c++  java
  • 分页及页码导航 用户控件

    该控件成形如图:

    主要功能如下:
    用户设置每页行数 (或者不设置 则该控件默认每页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();
        }


  • 相关阅读:
    24)django-信号
    23)django-缓存
    22)django-中间件
    21)django-csrf(跨站请求伪造)
    20)django-session使用
    19)django-cookie使用
    18)django-模板的过滤器和tag,自定义simple_tag和filter
    17)django-模板的继承与导入
    document.documentElement.clientHeight 和 document.body.clientHeight
    Markdown 入门基础
  • 原文地址:https://www.cnblogs.com/freeliver54/p/607331.html
Copyright © 2011-2022 走看看