datalist分页第二页无法显示数据……急急急
存储过程如下:
@pagesize int ,--每页记录数
@currentpage int,--当前页
@wh_month varchar(15),--维护月份
@wh_baoyang varchar(20),--保养要求
@pagecount int output,--总记录数
@pages int output--总页数
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @page int
declare @sql nvarchar(1000)
declare @numtemp int
-- Insert statements for procedure here
/*set @sql='select @pc= count(*) from (select B_device.zichannum,b_device.baoyang,b_device.devicename,
b_device.cfadress,weihu_v.wh_date,weihu_v.wh_id,wh_danhao from weihu_v left outer join B_device on
weihu_v.zch_num= b_device.zichannum) #temptable where wh_id<>'''' and baoyang like ''%'+@wh_baoyang+'%'' and wh_date like ''%'+@wh_month+'%'' '
exec sp_executesql @sql,N'@pc int output',@page output*/
select @pagecount=count(*) from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month
if @pagecount=0
begin
set @pages=1
end
else
begin
set @numtemp=@pagecount%@pagesize
if @numtemp=0
begin
set @pages=(@pagecount/@pagesize)
end
else
begin
set @pages=@pagecount/@pagesize+1
end
end
--if @currentpage=1
--begin
select * from (select top ((@currentpage)*(@pagesize)) row_number()over(order by wh_id desc)id , * from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month)t where id>((@currentpage-1)*(@pagesize)) order by wh_id desc
cs代码如下:
protected void BindDataList(int pindex)
{
// Response.Write("{0} {1} {2}{3}", PDS.PageSize, Convert.ToInt32(curpage.Text), year.SelectedItem.Text + DropDownList1.SelectedItem.Text,DropDownList4.SelectedItem.Text);
SqlCommand Command = new SqlCommand();
PagedDataSource PDS = new PagedDataSource();
PDS.AllowPaging = true;
PDS.PageSize = 15;
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
Command.Connection = conn;
Command.CommandType = CommandType.StoredProcedure;
Command.CommandText = "WH_finishpage";
SqlParameter page = new SqlParameter("@pagesize", SqlDbType.Int);
page.Value = PDS.PageSize;
Command.Parameters.Add(page);
SqlParameter current = new SqlParameter("@currentpage", SqlDbType.Int);
current.Value = pindex;
Command.Parameters.Add(current);
SqlParameter month = new SqlParameter("@wh_month", SqlDbType.VarChar, 20);
month.Value ="%"+ year.SelectedItem.Text + "-" + DropDownList1.SelectedItem.Text+"%";
Command.Parameters.Add(month);
SqlParameter baoyang = new SqlParameter("@wh_baoyang", SqlDbType.VarChar, 20);
baoyang.Value ="%"+ DropDownList4.SelectedItem.Text+"%";
Command.Parameters.Add(baoyang);
SqlParameter pcount = new SqlParameter("@pagecount", SqlDbType.In