AspNetPager控件一點使用

    最近因爲在做項目的時候,要用到分頁這個功能,自己在網上找了點資料,找到了一個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();
       

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章