数据分页一直以来是比较头疼的问题,不少的分页控件也随之产生。但是我用过的几个控件,本身都要执行SQL,对存储过程支持不好,为了方便,特别写了个通用分页类,利用PagedDataSource来实现DataGrid,DataList,Repeater的分页。完成上一页,下一页,
最后一页,最前一页,总页数,当前页数,跳转这些基本的功能。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace aspnetpager
{
///
/// netpager-本类提供datagrid,datalist,repeater的通用分页---jierry 04-7-19
///
public class netpager: System.Web.UI.Page
{
private System.Web.UI.WebControls.DataGrid datagrid=null;
private System.Web.UI.WebControls.DataList datalist=null;
private System.Web.UI.WebControls.Repeater repeater=null;
private System.Web.UI.WebControls.HyperLink lnknext;
private System.Web.UI.WebControls.HyperLink lnkprev;
private System.Web.UI.WebControls.HyperLink lnkfist;
private System.Web.UI.WebControls.HyperLink lnklast;
private System.Web.UI.WebControls.HyperLink lnkjump;
private System.Web.UI.WebControls.Label pagenum;
private System.Web.UI.WebControls.Label pagecount;
private System.Web.UI.WebControls.DropDownList list;
public netpager()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public System.Web.UI.WebControls.DataGrid Datagrid
{
get
{
return this.datagrid;
}
set
{
this.datagrid=value;
}
}
public System.Web.UI.WebControls.DataList Datalist
{
get
{
return this.datalist;
}
set
{
this.datalist=value;
}
}
public System.Web.UI.WebControls.Repeater Repeater