//将两个输出参数的输出方向指定
pars[2].Direction = ParameterDirection .Output;
pars[3].Direction = ParameterDirection .Output;
//将参数集合 加入到 查询命令对象中
sda.SelectCommand.Parameters.AddRange(pars);
//设置 查询命令类型 为存储过程
sda.SelectCommand.CommandType = CommandType .StoredProcedure;
//执行存储过程
sda.Fill(dtcalss);
//执行完后 将存储过程 获得的 两个输出参数值 赋给此方法的两个输出参数
rowCount = Convert .ToInt32(pars[2].Value);
pageCount = Convert .ToInt32(pars[3].Value);
}
return dtcalss;
}
存储过程up_GetPageData2
View Code
create proc up_GetPageData2
@LastRowIndex int , ---上一页的最后一行的下标
@pgSize float , --页容量
@rowCount int output, --- 输出总行数
@pgCount int output, --- 输出 总页数
@isDel bit --数据是否删除
as
begin
select @rowCount =count (*) from classes where cisdel= @isDel --查出总行数
set @pgCount =ceiling ( @rowCount/ @pgSize )-- 算出总页数
select * from (
select Row_Number () over ( order by cid ) as RNum, * from classes where cisdel= @isDel
) as temp
where RNum >@LastRowIndex and RNum <= @LastRowIndex +@pgSize
end
ListView.aspx代码如下:
View Code
<% @ Page Language="C#" AutoEventWireup="true" CodeBehind="ListView.aspx.cs" Inherits ="WebForm.ListView" %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">








