??? 最近因为在做项目的时候,要用到分页这个功能,自己在网上找了点资料,找到了一个AspNetPager第三方控件,也在网上找了下例子,发现此控件的做得很强大,集合了Datailst,GridView等的相关属性和事件,很值得学下,现在和大家分享下,分页功能达到了我最初想要的效果,呵呵
?
????? 一:主要是想运用下AspNetPager的分页功能 ????? 二:下面我说下要实现的功能 ????????? 我想在repeater控件上实现分页功能 ????? 三:具体步骤 ????????? 我在网上查了下关于AspNetPager控件的使用和自己在网上也找了例子来研究
????????? 我在sqlserver2005中创建了两个存储过程 “p_Get_ArrangeDetailFilm”用于获取表中有多少条记录,存储过程带了一个参数“@arrangeDetailID”,
???????? 存储过程:create proc [dbo].[p_Get_ArrangeDetailFilm] ( @F_ARRANGE_DETAIL_ID int ) as select count(*) from T_FILM_INFO where F_FILM_INFO_ID in (select F_FILM_INFO_ID from T_ARRANGE_FILM where F_ARRANGE_DETAIL_ID =@F_ARRANGE_DETAIL_ID)
???????? 后台调用存储过程的相关代码 ???????? private void ExcuteProc(int arrangeDetailID) ??? { ??????? SqlParameter para = new SqlParameter("@F_ARRANGE_DETAIL_ID",SqlDbType.Int); ??????? para.Value = arrangeDetailID;
??????? string conStr = SqlHelper.ConnectionStringLocalTransaction; ??????? int totalOrders = (int)SqlHelperOwn.ExecuteScalar(CommandType.StoredProcedure,"p_Get_ArrangeDetailFilm",para); ??????? AspNetPager1.RecordCount = totalOrders; ??? } ?????????? 另外一个存储过程“P_Get_Details_Film”,用户获取表中的所有信息,此存储过程带来三个参数“@F_ARRANGE_DETAIL_ID”,“@startIndex”,“@endIndex” ???????? 存储过程:??????????
?????? ALTER PROCEDURE [dbo].[P_Get_Details_Film] ( ?@F_ARRANGE_DETAIL_ID INT, ?@startIndex INT, ?@endindex INT ?) as set nocount on declare @indextable table(id int identity(1,1),nid int) set rowcount @endIndex insert into @indextable(nid) select F_FILM_INFO_ID from T_FILM_INFO where? F_FILM_INFO_ID in (select F_FILM_INFO_ID from T_ARRANGE_FILM where F_ARRANGE_DETAIL_ID =@F_ARRANGE_DETAIL_ID) select T.* from T_FILM_INFO T inner join @indextable i on T.F_FILM_INFO_ID=i.nid where i.id between @startIndex and @endIndex order by i.id set nocount off ?RETURN
?????????? 后台调用相关代码 ?????????? int id = int.Parse(Request.QueryString["ID"]);
??????????? Repeater1.DataSource = SqlHelperOwn.ExecuteReader(CommandType.StoredProcedure,ConfigurationManager.AppSettings["pagedSPName"],??????????? new SqlParameter("@F_ARRANGE_DETAIL_ID",id),??????????? new SqlParameter("@startIndex",AspNetPager1.StartRecordIndex),??????????? new SqlParameter("@endIndex",AspNetPager1.EndRecordIndex));??????????? Repeater1.DataBind();???????
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|