<%
...
@ Control Language="c#" AutoEventWireup="false" Codebehind="UCPaginationDG.ascx.cs" Inherits="XHQ.HbKyHR.WebHbKyHR.UserControl.UCPaginationDG" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"
%>
<
table
cellSpacing
="1"
cellPadding
="0"
width
="100%"
bgColor
="#ffa553"
border
="0"
>
<
tr
align
="left"
bgColor
="#ffdbbb"
>
<
td
colSpan
="2"
height
="22"
vAlign
="bottom"
>
共
<
asp:label
id
="lblRecordsCount"
runat
="server"
>
0
</
asp:label
>
条 分
<
asp:label
id
="lblPageCount"
runat
="server"
>
0
</
asp:label
>
页 当前第
<
asp:label
id
="lblCurrPage"
runat
="server"
>
1
</
asp:label
>
页
<
asp:ImageButton
id
="imgBtn_FirstPage"
runat
="server"
ImageUrl
="../Images/fy1.gif"
CausesValidation
="False"
CommandName
="First"
OnCommand
="Page_OnClick"
></
asp:ImageButton
>
<
asp:linkbutton
id
="ctrl_PrevPage"
runat
="server"
OnCommand
="Page_OnClick"
CausesValidation
="False"
CommandName
="prev"
>
上一页
</
asp:linkbutton
>
<
asp:linkbutton
id
="ctrl_NextPage"
runat
="server"
OnCommand
="Page_OnClick"
CausesValidation
="False"
CommandName
="next"
>
下一页
</
asp:linkbutton
>
<
asp:ImageButton
id
="imgBtn_LastPage"
runat
="server"
ImageUrl
="../Images/fy2.gif"
CausesValidation
="False"
CommandName
="Last"
OnCommand
="Page_OnClick"
></
asp:ImageButton
>
转到
<
asp:textbox
id
="txtToPage"
runat
="server"
Width
="25px"
CssClass
="InputCss"
MaxLength
="4"
></
asp:textbox
>
页
<
asp:RequiredFieldValidator
id
="RequiredFieldValidator1"
runat
="server"
ErrorMessage
="请填写跳转得页码"
Display
="Dynamic"
ControlToValidate
="txtToPage"
></
asp:RequiredFieldValidator
>
<
asp:regularexpressionvalidator
id
="RegularExpressionValidator1"
ErrorMessage
="跳转页码必须为正整数"
Display
="Dynamic"
ValidationExpression
="^[1-9]{1,3}"
ControlToValidate
="txtToPage"
Runat
="server"
></
asp:regularexpressionvalidator
>
<
asp:ImageButton
id
="imgBtnSubmitPage"
runat
="server"
ImageAlign
="Bottom"
ImageUrl
="../Images/go.gif"
></
asp:ImageButton
>
</
td
>
</
tr
>
</
table
>
namespace
UserControl
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using XHQ.HbKyHR.MyComponet.DycnamicalSystem;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// UCPaginationDG 的摘要说明。
/// </summary>
public class UCPaginationDG : System.Web.UI.UserControl
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
protected System.Web.UI.WebControls.LinkButton ctrl_PrevPage;
protected System.Web.UI.WebControls.LinkButton ctrl_NextPage;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//查询数据参数
private string _sourceid; //数据源表
private int _dbNameid; //数据类型ID
private int _sysid; //所属系统ID
private string _condition; //查询条件
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//翻页所需参数
private DataSet _dataSource; //绑定数据源
private System.Web.UI.Control _ctrlData;//需要绑定得控件
private int _pageNo = 1; //当前页码
private int _pageSize = 15; //分页大小
private int _recordCount = 0; //记录条数
protected System.Web.UI.WebControls.Label lblRecordsCount; //总得记录数
protected System.Web.UI.WebControls.Label lblPageCount; //总得页数
protected System.Web.UI.WebControls.Label lblCurrPage; //当前页码
private bool _isAllDisplay = true; //是否显示全部列
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtToPage;
protected System.Web.UI.WebControls.ImageButton imgBtnSubmitPage;
protected System.Web.UI.WebControls.ImageButton imgBtn_LastPage;
protected System.Web.UI.WebControls.ImageButton imgBtn_FirstPage; //是否显示全部列
private bool _isConvertColName = true; //是否转换列名
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
翻页控件属性集合#region 翻页控件属性集合
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 设置要绑定得控件:DataGrid,DataList,Repeater
/// </summary>
public System.Web.UI.Control CtrlData
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
get
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
return _ctrlData;
}
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_ctrlData = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 查询条件
/// </summary>
public string Condition
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if(value != String.Empty)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_condition = value;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_condition = null;
}
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 是否显示全部列
/// </summary>
public bool IsAllDisplay
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_isAllDisplay = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 是否转换列名
/// </summary>
public bool IsConvertColName
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_isConvertColName = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 数据源ID
/// </summary>
public string SourceId
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_sourceid = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 数据类型
/// </summary>
public int DbNameId
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_dbNameid = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 所属系统ID
/// </summary>
public int SysId
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_sysid = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 当前页码(查询时,若不对此参数赋值,则是在当前页中进行查找)
/// </summary>
public int PageCurrNo
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
get
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if(ViewState["CurrentPage"] == null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_pageNo = 1;
ViewState["CurrentPage"] = 1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
return _pageNo;
}
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_pageNo = value;
ViewState["CurrentPage"] = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 分页大小(默认为15)
/// </summary>
public int PageSize
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
set
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
_pageSize = value;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void Page_Load(object sender, System.EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if(!this.IsPostBack)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//初始化页码值
ViewState["CurrentPage"] = _pageNo;
//第一绑定值
BindDataToControl();
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
绑定数据到指定的控件:DataGrid,DataList,Repeater#region 绑定数据到指定的控件:DataGrid,DataList,Repeater
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 绑定数据到指定控件
/// </summary>
public void BindDataToControl()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
string strControlType = ""; //控件类型
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//取得绑定数据,并设置翻页信息
GetBindData();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
if(_ctrlData != null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
strControlType = _ctrlData.GetType().ToString();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//根据控件类型绑定数据
switch(strControlType)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
case "System.Web.UI.WebControls.DataGrid":
((DataGrid)_ctrlData).DataSource = _dataSource;
((DataGrid)_ctrlData).DataBind();
break;
case "System.Web.UI.WebControls.DataList":
((DataList)_ctrlData).DataSource = _dataSource;
((DataList)_ctrlData).DataBind();
break;
case "System.Web.UI.WebControls.Repeater":
((Repeater)_ctrlData).DataSource = _dataSource;
((Repeater)_ctrlData).DataBind();
break;
}
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
throw new ArgumentNullException("CtrlData","未设置需绑定控件参数或者该参数无效!");
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
取得绑定的数据源,并设置页面分页属性#region 取得绑定的数据源,并设置页面分页属性
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 取得绑定数据
/// </summary>
private void GetBindData()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//需要绑定的页码
int iNextPageIndex = (int)ViewState["CurrentPage"];
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//判断必须的参数是_sourceid,_sysid,_dbNameid否赋值
if(_sourceid == null || _sourceid == String.Empty)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
throw new ArgumentNullException("参数不能为空","SourceId");
}
if(_sysid == 0)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
throw new ArgumentNullException("参数不能为空","SysId");
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
if(_dbNameid == 0)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
throw new ArgumentNullException("参数不能为空","DbNameId");
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
DynamicalBindDataGrid dycBindGrid = new DynamicalBindDataGrid();
dycBindGrid.PageSize = this._pageSize;
dycBindGrid.PageNo = iNextPageIndex;
dycBindGrid.IsPagination = true;
dycBindGrid.IsAllDisplay = _isAllDisplay;
dycBindGrid.IsConvertColumnName = _isConvertColName;
dycBindGrid.Sourceid = this._sourceid;
dycBindGrid.SysId = _sysid;
dycBindGrid.DbNameID = this._dbNameid;
dycBindGrid.Condition = _condition;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//取得数据源
_dataSource = dycBindGrid.QueryData();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//取得记录数
this._recordCount = dycBindGrid.RecordCount;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
this.lblRecordsCount.Text = _recordCount.ToString();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//计算页数
int iPageCount = 0;
iPageCount = (int)_recordCount/_pageSize;
int iResi = _recordCount%_pageSize; //取余数
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
if(iResi != 0)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
iPageCount += 1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
this.lblPageCount.Text = iPageCount.ToString();
this.lblCurrPage.Text = iNextPageIndex.ToString();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//判断是否是第一页
if(iNextPageIndex == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
ctrl_PrevPage.Enabled = false;
imgBtn_FirstPage.Enabled = false;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
ctrl_PrevPage.Enabled = true;
imgBtn_FirstPage.Enabled = true;
imgBtnSubmitPage.Enabled = true;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//判断是否到达最后一页
if(iNextPageIndex == iPageCount)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
ctrl_NextPage.Enabled = false;
imgBtn_LastPage.Enabled = false;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
ctrl_NextPage.Enabled = true;
imgBtn_LastPage.Enabled = true;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//只有一页,跳转按钮不可用
if(iPageCount == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
imgBtn_FirstPage.Enabled = false;
imgBtn_LastPage.Enabled = false;
this.imgBtnSubmitPage.Enabled = false;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
自定义翻页事件(上一页,下一页事件)#region 自定义翻页事件(上一页,下一页事件)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 自定义分页事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void Page_OnClick(Object sender,CommandEventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//当前页号
int iPageNo;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
iPageNo = (int)ViewState["CurrentPage"];
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//事件命令参数:prev 上一页,next 下一页
string strCmdArgs = e.CommandName.ToUpper();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//根据cmd判定翻页方向
switch(strCmdArgs)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
case "NEXT":
iPageNo ++;
break;
case "PREV":
iPageNo --;
break;
case "LAST":
iPageNo = int.Parse(lblPageCount.Text);
break;
case "FIRST":
iPageNo = 1;
break;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
this.ViewState["CurrentPage"] = iPageNo;
//重新绑定数据
BindDataToControl();
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
this.imgBtnSubmitPage.Click += new System.Web.UI.ImageClickEventHandler(this.imgBtnSubmitPage_Click);
this.Load += new System.EventHandler(this.Page_Load);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
}
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void imgBtnSubmitPage_Click(object sender, System.Web.UI.ImageClickEventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//跳转页
int iPageNo = Convert.ToInt32(txtToPage.Text);
this.ViewState["CurrentPage"] = iPageNo;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
BindDataToControl();
}
}
}
存储过程:
PROCEDURE p_pagequery (
p_pagesize INT, --每页记录数
p_pageno INT, --当前页码,从 1 开始
p_sqlselect VARCHAR2, --查询语句,含排序部分
p_selcolumn VARCHAR2, --查询列信息
p_sqlcount VARCHAR2, --获取记录总数的查询语句
p_outrecordcount OUT INT, --返回总记录数
cur_out OUT pkg_admin.T_RefCursor
)
IS
/*********************************************************************
1. 名称 【p_pagequery】
2. 用途 B/S, C/S 分页查询
3. 版本
版本号 日期 执行人 日志记录 当前状态
---------------------------------------------------------------------------
1>
2>
4. 备注
**********************************************************************/
v_sql VARCHAR2 (3000);
v_count INT;
v_heirownum INT;
v_lowrownum INT;
BEGIN
----取记录总数
EXECUTE IMMEDIATE p_sqlcount
INTO v_count;
p_outrecordcount := v_count;
----执行分页查询
v_heirownum := p_pageno * p_pagesize;
v_lowrownum := v_heirownum - p_pagesize + 1;
v_sql :=
'SELECT '
|| p_selcolumn
|| '
FROM (
SELECT A.*, rownum rn
FROM ('
|| p_sqlselect
|| ') A
WHERE rownum <= '
|| TO_CHAR (v_heirownum)
|| '
) B
WHERE rn >= '
|| TO_CHAR (v_lowrownum);
DBMS_OUTPUT.put_line (v_sql);
OPEN cur_out FOR v_sql;
END p_pagequery;