分页及页码导航 用户控件

该控件成形如图:

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


 http://www.cnblogs.com/freeliver54/archive/2006/12/29/607331.aspx

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值