存储过程改自bigeagle的论坛分页程序。请大家批判!)
select.aspx
--------------------------------------------------------------------------------
%26lt;%@ Page Language=C# %%26gt;
%26lt;%@ import Namespace=System.Data %%26gt;
%26lt;%@ import Namespace=System.Data.SqlClient %%26gt;
%26lt;script runat=server%26gt;
protected void Page_Load(Object sender, EventArgs e)
{
int intPageNo,intPageSize,intPageCount;
intPageSize = 25;
if (Request[CurrentPage]==null)
{
intPageNo = 1;
}
else
{
intPageNo = Int32.Parse(Request[CurrentPage]);
}
SqlConnection mySqlConnection = new SqlConnection(server=(local);Database=test;user id=sa;password=);
SqlCommand mySqlCommand = new SqlCommand(up_GetTopicList, mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;
SqlParameter workParm;
//搜索表字段,以,号分隔
workParm = mySqlCommand.Parameters.Add(@a_TableList, SqlDbType.VarChar, 200);
mySqlCommand.Parameters[@a_TableList].Value = OFFERID,type,offertime;
//搜索表名
workParm = mySqlCommand.Parameters.Add(@a_TableName, SqlDbType.VarChar, 30);
mySqlCommand.Parameters[@a_TableName].Value = offer;
//搜索条件,如select * from aa where a=1 and b=2 and c=3则条件为where a=1 and b=2 and c=3
workParm = mySqlCommand.Parameters.Add(@a_SelectWhere, SqlDbType.VarChar, 500);
mySqlCommand.Parameters[@a_SelectWhere].Value = where type='idl';
//表主键字段名,必须为INT类型
workParm = mySqlCommand.Parameters.Add(@a_SelectOrderId, SqlDbType.VarChar, 50);
mySqlCommand.Parameters[@a_SelectOrderId].Value = offerid;
//排序,可以使用多字段排序但主键字段必需在最前面
workParm = mySqlCommand.Parameters.Add(@a_SelectOrder, SqlDbType.VarChar, 50);
mySqlCommand.Parameters[@a_SelectOrder].Value = order by offerid desc;
//页号
workParm = mySqlCommand.Parameters.Add(@a_intPageNo, SqlDbType.Int);
mySqlCommand.Parameters[@a_intPageNo].Value = intPageNo;
//每页显示数
workParm = mySqlCommand.Parameters.Add(@a_intPageSize, SqlDbType.Int);
mySqlCommand.Parameters[@a_intPageSize].Value = intPageSize;
//总记录数(存储过程输出参数)
workParm = mySqlCommand.Parameters.Add(@RecordCount, SqlDbType.Int);
workParm.Direction = ParameterDirection.Output;
//当前页记录数(存储过程返回值)
workParm = mySqlCommand.Parameters.Add(RowCount, SqlDbType.Int);
workParm.Direction = ParameterDirection.ReturnValue;
mySqlConnection.Open();
Repeater.DataSource = mySqlCommand.ExecuteReader();
Repeater.DataBind();
mySqlConnection.Close();
Int32 RecordCount = (Int32)mySqlCommand.Parameters[@RecordCount].Value;
Int32 RowCount = (Int32)mySqlCommand.Parameters[RowCount].Value;
LabelRecord.Text = RecordCount.ToString();
LabelRow.Text = intPageNo.ToString();
intPageCount = RecordCount/intPageSize;
if ((RecordCount%intPageSize)%26gt;0)
intPageCount += 1;
LabelPage.Text = intPageCount.ToString();
if (intPageNo%26gt;1)
{
HLFistPage.NavigateUrl = select.aspx?CurrentPage=1;
HLPrevPage.NavigateUrl = String.Concat(select.aspx?CurrentPage=,,intPageNo-1);
}
else
{
HLFistPage.NavigateUrl = ;
HLPrevPage.NavigateUrl = ;
//HLFistPage.Enabled = false;
//HLPrevPage.Enabled = false;
}
if (intPageNo%26lt;intPageCount)
{
HLNextPage.NavigateUrl = String.Concat(select.aspx?CurrentPage=,,intPageNo+1);
HLEndPage.NavigateUrl = String.Concat(select.aspx?CurrentPage=,,intPageCount);
}
else
{
HLNextPage.NavigateUrl = ;
HLEndPage.NavigateUrl = ;
//HLNextPage.Enabled=false;
//HLEndPage.Enabled=false;
}
}
%26lt;/script%26gt;
%26lt;html%26gt;
%26lt;meta http-equiv=Content-Type content=text/html; charset=gb2312%26gt;
%26lt;head%26gt;
%26lt;link /style.css rel=stylesheet /%26gt;
%26lt;style type=text/css%26gt;
.high { font-family: 宋体; font-size: 9pt; line-height: 140%}
.mid { font-size: 9pt; line-height: 12pt}
.small { font-size: 9pt; line-height: normal}
.TP10_5 {
font-size: 14px;
line-height: 140%;
}
%26lt;/style%26gt;
%26lt;style type=text/css%26gt;A:link {
COLOR: #cc6666
}
%26lt;/style%26gt;
%26lt;/head%26gt;
%26lt;body%26gt;
%26lt;form runat=server%26gt;
%26lt;span class=high%26gt; 第%26lt;font color=#CC0000%26gt;%26lt;asp:Label id=LabelRow runat=server/%26gt;%26lt;/font%26gt;页 | 共有%26lt;asp:Label id=LabelPage runat=server/%26gt;页
| %26lt;asp:Label id=LabelRecord runat=server/%26gt;条信息 |
%26lt;asp:HyperLink id=HLFistPage Text=首页 runat=server/%26gt;
| %26lt;asp:HyperLink id=HLPrevPage Text=上一页 runat=server/%26gt;
| %26lt;asp:HyperLink id=HLNextPage Text=下一页 runat=server/%26gt;
| %26lt;asp:HyperLink id=HLEndPage Text=尾页 runat=server/%26gt;%26lt;/span%26gt;%26lt;br%26gt;
%26lt;asp:Repeater id=Repeater runat=server%26gt;
%26lt;HeaderTemplate%26gt;
%26lt;table width=583 border=0 cellspacing=0 cellpadding=0%26gt;
%26lt;tr%26gt;
%26lt;td bgcolor=#000000%26gt;%26lt;table width=100% border=0 cellpadding=4 cellspacing=1 class=TP10_5%26gt;
%26lt;tr bgcolor=#999999%26gt;
%26lt;td align=center%26gt; %26lt;strong%26gt;%26lt;font color=#FFFFFF%26gt;订单号%26lt;/font%26gt;%26lt;/strong%26gt;%26lt;/td%26gt;
%26lt;td align=center%26gt; %26lt;strong%26gt;%26lt;font color=#FFFFFF%26gt;服务项目%26lt;/font%26gt;%26lt;/strong%26gt;%26lt;/td%26gt;
%26lt;td align=center%26gt; %26lt;strong%26gt;%26lt;font color=#FFFFFF%26gt;预订日期%26lt;/font%26gt;%26lt;/strong%26gt;%26lt;/td%26gt;
%26lt;td align=center%26gt; %26lt;strong%26gt;%26lt;font color=#FFFFFF%26gt;操作人员%26lt;/font%26gt;%26lt;/strong%26gt;%26lt;/td%26gt;
%26lt;td align=center%26gt; %26lt;strong%26gt;%26lt;font color=#FFFFFF%26gt;分配状态%26lt;/font%26gt;%26lt;/strong%26gt;%26lt;/td%26gt;
%26lt;td%26gt; %26lt;div align=center%26gt;%26lt;/div%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;/HeaderTemplate%26gt;
%26lt;ItemTemplate%26gt;
%26lt;tr align=center bgcolor=#FFFFFF class=small ,
@SPintEndID=@intEndID,@SPintBeginID=@intBeginID
return(@@rowcount)
--select @@rowcount
GO

您当前的位置: