日期:2014-05-17 浏览次数:20471 次
if exists(select *from sysobjects where name='gettest') drop proc gettest go create proc gettest @startIndex INT, @pageSize INT AS with SClass as( select row_number() over(order by id) as rownumber,id,custname,addtime from company) /**上半句产生一个临时表,表名为Small_Class,其内容来自于自查询select row_number().......**/ select rownumber, id,custname,addtime from SClass where rownumber >=(@startindex-1)*@pagesize+1 and rownumber<=(@startindex-1)*@pagesize+(@pagesize) select count(*) from company
DataSet ds = new DataSet(); DataTable dt = new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SetBind(); } } protected void SetBind() { ds = getmes(AspNetPager1.CurrentPageIndex, 20); dt = ds.Tables[0]; AspNetPager1.RecordCount = int.Parse(ds.Tables[1].Rows[0][0].ToString()); Repeater1.DataSource = dt; Repeater1.DataBind(); } protected void PageChanged(object sender, EventArgs e) { SetBind(); } protected DataSet getmes(int startindex, int pagesize) { SqlParameter[] par = { new SqlParameter("@startindex",SqlDbType.Int), new SqlParameter("@pagesize",SqlDbType.Int) }; par[0].Value = startindex; par[1].Value = pagesize; return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionString, CommandType.StoredProcedure, "gettest", par); }