同时返回记录总数及数据集
int iRecordCount = 1;
Model.UserInfor us = new Model.UserInfor();
us.PageIndex = AspNetPager1.CurrentPageIndex.ToString();
us.PageSize = AspNetPager1.PageSize.ToString();
us.OrderName = orderByName;
us.OrderType = orderByType;
us.UserName = strUserName;
us.Email = strEmail;
BLL.UserInfor tmp = new BLL.UserInfor();
myGridView.DataSource = tmp.ListUsersMsg(us, out iRecordCount);
myGridView.DataBind();
AspNetPager1.RecordCount = iRecordCount;
public DataTable ListUsersMsg(Model.UserInfor users, out int iRecordCount)
{
iRecordCount = 1;
string[] list = new string[] { "@RecordCount", "@PageIndex", "@PageSize", "@OrderName", "@OrderType", "@strUserName", "@strEmail" };
string[] type = new string[] { "int", "int", "int", "", "", "", "" };
string[] dir = new string[] { "Out", "", "", "", "", "", "" };
string[] val = new string[] { "", users.PageIndex, users.PageSize, users.OrderName, users.OrderType, users.UserName, users.Email };
SQLDBClass.ExecuteSQL tmp = new SQLDBClass.ExecuteSQL(list, type, dir, val);
DataTable dt= tmp.GetDataTable("SP_ListUsersMsg");
iRecordCount = int.Parse(tmp.ParaValue[0].ToString());
return dt;
}
/*
Author:Jin
Date:2008/07/10
Note:用户基本信息显示
*/
ALTER PROCEDURE [dbo].[SP_ListUsersMsg]
(
@RecordCount int output,
@PageIndex int,
@PageSize int,
@OrderName varchar(50),
@OrderType varchar(20),
@strUserName nvarchar(50),
@strEmail varchar(100)
)
AS
declare @strsql varchar(1000)
set @strsql=''
if(@strUserName<>'')
begin
set @strsql=@strsql+'and username like ''%'+@strUserName+'%'' '
end
if(@strEmail<>'')
begin
set @strsql=@strsql+'and email like ''%'+@strEmail+'%'' '
end
declare @strwherecount nvarchar(2000),@strwhere varchar(2000)
set @strwherecount='select @RecordCount=count(id) FROM users where end_mk=0 '+@strsql
set @strwhere='end_mk=0'+@strsql
execute sp_executesql @strwherecount, N'@RecordCount int output',@RecordCount output
EXEC GetRecordFromPage @PageIndex,@PageSize,'VW_UsersList',
'id,conid,deptid,username,email,userno,jobs,sex,lgtime,lgIP,stime,end_mk,conames,deptname',
@OrderName,@OrderType,@strwhere
浙公网安备 33010602011771号