




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、三層+存儲(chǔ)過程實(shí)現(xiàn)分頁示例代碼_ 前臺(tái)設(shè)計(jì): 代碼如下: % Page Language=C# AutoEventWireup=true CodeBehind=paging.aspx.cs Inherits=五二一練習(xí).paging % !DOCTYPE html PUBLIC -/W3C/DTD XHTML 1.0 Transitional/EN l1/DTD/xhtml1-transitional.dtd html xmlns=l head runat=server title/title script src=js/Jquery1.7.js type=text/javascript/sc
2、ript script type=text/javascript $(function () $(#txtPagination).focus(function () $(this).val(); ) ) /script /head body form id=form1 runat=server div asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False Height=336px Width=685px Columns asp:BoundField DataField=Id HeaderText=編號(hào) / asp:Bo
3、undField DataField=NewsTitle HeaderText=標(biāo)題 / asp:BoundField DataField=NewsContent HeaderText=內(nèi)容 / asp:BoundField DataField=CreateTime DataFormatString=0:yyyy-MM-dd hh:mm:ss HeaderText=發(fā)布時(shí)間 / /Columns /asp:GridView asp:LinkButton ID=btnFirst runat=server onclick=btnFirst_Click第一頁/asp:LinkButton asp:L
4、inkButton ID=btnPre runat=server onclick=btnPre_Click上一頁/asp:LinkButton asp:LinkButton ID=btnNext runat=server onclick=btnNext_Click下一頁/asp:LinkButton asp:LinkButton ID=btnLast runat=server onclick=btnLast_Click最終一頁/asp:LinkButtonasp:TextBox ID=txtPagination runat=server/asp:TextBox asp:LinkButton I
5、D=btnSkip runat=server onclick=btnSkip_ClickGO/asp:LinkButton /div /form /body /html 首先在數(shù)據(jù)庫創(chuàng)建存儲(chǔ)過程 代碼如下: create proc usp_role_GetDateByPageIndex pageSize int, pageIndex int as begin select * from ( select *,ROW_NUMBER() over(order by role_id) as rownumber from role) as tbl where tbl.rownumber between
6、 (pageSize*(pageIndex-1)+1) and pageIndex*pageSize end exec usp_role_GetDateByPageIndex 5,3 在項(xiàng)目中添加BLL,DAL,DataAccess,MODEL層 在DAL中寫一個(gè)方法: 代碼如下: /自己寫的方法,分頁獵取數(shù)據(jù)列表 public DataTable GetListDataTable(int PageSize, int PageIndex) SqlParameter parameters = new SqlParameter(PageSize, SqlDbType.Int), new SqlPa
7、rameter(PageIndex, SqlDbType.Int) ; parameters0.Value = PageSize; parameters1.Value = PageIndex; return DbHelperSQL.RunProcedureDataTable(usp_role_GetDateByPageIndex, parameters); 在BLL中調(diào)用GetListDataTable: public DataTable GetListDataTable(int pagesize, int pageindex) return dal.GetListDataTable(page
8、size, pageindex); 在DbHelper中添加RunProcedureDataTable方法: public static DataTable RunProcedureDataTable(string stroreProcName, IDataParameter parameters) using (SqlConnection connection = new SqlConnection(connectionString) DataTable dt = new DataTable(); connection.Open(); SqlDataAdapter sqlDA = new S
9、qlDataAdapter(); sqlDA.SelectCommand = BuildQueryCommand(connection, stroreProcName, parameters); sqlDA.Fill(dt); connection.Close(); return dt; 然后在后臺(tái)調(diào)用即可: 代碼如下: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
10、 using System.Data; namespace 練習(xí) public partial class paging : System.Web.UI.Page int pagesize = 10; int pageindex = 1; protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) ViewStatepageindex = 1; LadaData(); GetListPageindex(); private void GetListPageindex() BLL.T_News1 bnews = ne
11、w BLL.T_News1(); int totalcount = bnews.GetRecordCount(); if (totalcount % pagesize = 0) ViewStatelastpageindex = totalcount / pagesize; else ViewStatelastpageindex = totalcount / pagesize + 1; private void LadaData() BLL.T_News1 bnews = new BLL.T_News1(); DataTable dt = bnews.GetListDataTable(pages
12、ize, Convert.ToInt32(ViewStatepageindex); this.GridView1.DataSource = dt; this.GridView1.DataBind(); /第一頁 protected void btnFirst_Click(object sender, EventArgs e) ViewStatepageindex = 1; LadaData(); /上一頁 protected void btnPre_Click(object sender, EventArgs e) int pageindex = Convert.ToInt32(ViewSta
13、tepageindex); if (pagesize1) pageindex-; ViewStatepageindex = pageindex; LadaData(); /下一頁 protected void btnNext_Click(object sender, EventArgs e) int pageindex = Convert.ToInt32(ViewStatepageindex); if (pageindexConvert.ToInt32(ViewStatelastpageindex) pageindex+; ViewStatepageindex = pageindex; LadaData(); /最終一頁 protected void btnLast_Click(object sender, EventArgs e) ViewStatepageindex = ViewStatelastpageindex; LadaData(); /跳轉(zhuǎn)頁面 protected void btnSkip_C
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025標(biāo)準(zhǔn)網(wǎng)簽版建筑工程合同模板
- 2025企業(yè)租賃合同協(xié)議標(biāo)準(zhǔn)版
- 2025年降酶退黃類藥物合作協(xié)議書
- 2025技術(shù)轉(zhuǎn)讓合同范本(中英文對(duì)照)
- 2025年磐安縣農(nóng)產(chǎn)品收購合同
- 2025個(gè)人住宅庭院景觀規(guī)劃合同
- 2025二級(jí)建造師建筑實(shí)務(wù)知識(shí)點(diǎn):合同價(jià)款約定詳解
- 2025私營企業(yè)員工試用期合同模板
- 2025年外貿(mào)合同法律風(fēng)險(xiǎn)評(píng)估
- 2025年叔丁基苯酚項(xiàng)目合作計(jì)劃書
- 軟件質(zhì)量證明書
- 高考標(biāo)準(zhǔn)化考場(chǎng)建設(shè)方案詳細(xì)
- 人民醫(yī)院腫瘤科臨床技術(shù)操作規(guī)范2023版
- 高壓-引風(fēng)機(jī)電機(jī)檢修文件包
- 2023屆物理高考二模考前指導(dǎo)
- GB/T 39486-2020化學(xué)試劑電感耦合等離子體質(zhì)譜分析方法通則
- GB/T 11085-1989散裝液態(tài)石油產(chǎn)品損耗
- GXH-3011A1便攜式紅外線CO分析儀
- NYT 393-綠色食品 農(nóng)藥使用準(zhǔn)則
- 2022年四川省阿壩州中考數(shù)學(xué)試卷及解析
- 綜采工作面末采安全技術(shù)措施
評(píng)論
0/150
提交評(píng)論