如何在Asp.Net項(xiàng)目中實(shí)現(xiàn)一個(gè)分頁(yè)函數(shù)?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)懷化,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):13518219792功能:
1.每頁(yè)設(shè)置顯示9頁(yè),超過(guò)9頁(yè),點(diǎn)5頁(yè)后的+1頁(yè)顯示(可以隨便修改)
2.CSS樣式自己可以設(shè)置
3.無(wú)任何咋代碼產(chǎn)生,利于搜索引擎優(yōu)化
分頁(yè)程序
objPDS = new PagedDataSource(); objPDS.DataSource = dtTable.DefaultView;//綁定數(shù)據(jù)源 objPDS.AllowPaging = true; objPDS.PageSize =10;//分頁(yè)數(shù)目 int curPage; int cshi; int jshi; int zyes = Int32.Parse( objPDS.PageCount.ToString()); this.tjixx.Text = "總共 <font color=red>" + dtTable.Rows.Count + " </font>條信息"; this.tjixx.Text += "|共 <font color=red>" + zyes + " </font>頁(yè)"; if (Request.QueryString["Page"] != null) { if (Int32.Parse(Request.QueryString["Page"]) > zyes) curPage = zyes; else curPage = Int32.Parse(Request.QueryString["Page"]); } else { curPage = 1; } if (zyes <= 9) { cshi = 1; jshi = zyes; } else { if (curPage <= 5) { cshi = 1; jshi = 9; } else { cshi = curPage - 4; int jshils = curPage + 4; if (jshils > zyes) jshi = zyes; else jshi=curPage + 4; } } objPDS.CurrentPageIndex = curPage - 1; StringBuilder m_strPageInfo = new StringBuilder(); for (int i = cshi; i <=jshi; i++) { if (i == Int32.Parse(curPage.ToString())) m_strPageInfo.Append(" <span class=\"dqye\"> <strong>" + i + " </strong> </span> "); else m_strPageInfo.Append(" <span class=\"qtye\"> <strong> <a href=\"newslist_ej" + Request.QueryString["wzcat"] + "_Page" + i + ".html\">" + i + " </a> </strong> </span> "); } this.yemsl.Text = m_strPageInfo.ToString(); if (!objPDS.IsFirstPage) { linkPre.NavigateUrl = "newslist_ej" + Request.QueryString["wzcat"] + "_Page" + Convert.ToString(curPage - 1); linkPre.NavigateUrl += ".html"; } if (!objPDS.IsLastPage) { linkNext.NavigateUrl = "newslist_ej" + Request.QueryString["wzcat"] + "_Page" + Convert.ToString(curPage + 1); linkNext.NavigateUrl += ".html"; } linkFirstPage.NavigateUrl = "newslist_ej" + Request.QueryString["wzcat"] + "_Page1"; linkFirstPage.NavigateUrl += ".html"; linkEndPage.NavigateUrl = "newslist_ej" + Request.QueryString["wzcat"] + "_Page" + objPDS.PageCount.ToString(); linkEndPage.NavigateUrl += ".html"; this.DataList4.DataSource = objPDS;//綁定分頁(yè)的數(shù)據(jù) this.DataList4.DataBind();
Aspx文件:
分頁(yè)部分:
<div align="center"> <asp:HyperLink ID="linkFirstPage" runat="server" Font-Underline="False">首頁(yè) </asp:HyperLink><< <asp:HyperLink ID="linkPre" runat="server" Font-Underline="False">上一頁(yè) </asp:HyperLink> <asp:Literal ID="yemsl" runat="server"> </asp:Literal> <asp:HyperLink ID="linkNext" runat="server" Font-Underline="False">下一頁(yè) </asp:HyperLink> >> <asp:HyperLink ID="linkEndPage" runat="server" Font-Underline="False">尾頁(yè) </asp:HyperLink>| <asp:Literal ID="tjixx" runat="server"> </asp:Literal> </div>
關(guān)于如何在Asp.Net項(xiàng)目中實(shí)現(xiàn)一個(gè)分頁(yè)函數(shù)問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
當(dāng)前題目:如何在Asp.Net項(xiàng)目中實(shí)現(xiàn)一個(gè)分頁(yè)函數(shù)-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://aaarwkj.com/article16/cocodg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、域名注冊(cè)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站維護(hù)、網(wǎng)站導(dǎo)航、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)