GridView分頁代碼簡單萬能實(shí)用
更新時(shí)間:2012年12月28日 09:38:13 作者:
GridView在使用.net技術(shù)搭建的后臺(tái),在商品列表或者是信息列表經(jīng)常會(huì)出現(xiàn);它的作用在于有效的管理信息,增刪改查等等最主要的是還可以實(shí)現(xiàn)分頁,這一點(diǎn)是無可比靡的,接下來介紹如何使用GridView實(shí)現(xiàn)分頁,需要了解的朋友可以參考下
復(fù)制代碼 代碼如下:
<asp:GridView ID="GridViewHistory" runat="server" AutoGenerateColumns="False"
CssClass="vip_table" GridLines="None" BorderStyle="None" CellPadding="0"
ShowHeader="False" AllowPaging="true" PageSize="20"
onpageindexchanging="GridViewHistory_PageIndexChanging">
<PagerTemplate>
<asp:LinkButton ID="lb_firstpage" runat="server" onclick="lb_firstpage_Click">首頁</asp:LinkButton>
<asp:LinkButton ID="lb_previouspage" runat="server"
onclick="lb_previouspage_Click">上一頁</asp:LinkButton>
<asp:LinkButton ID="lb_nextpage" runat="server" onclick="lb_nextpage_Click">下一頁</asp:LinkButton>
<asp:LinkButton ID="lb_lastpage" runat="server" onclick="lb_lastpage_Click">尾頁</asp:LinkButton>
第<asp:Label ID="lbl_nowpage" runat="server" Text="<%#GridViewHistory.PageIndex+1 %>" ForeColor="#db530f"></asp:Label>頁/共<asp:Label
ID="lbl_totalpage" runat="server" Text="<%#GridViewHistory.PageCount %>" ForeColor="#db530f"></asp:Label>頁
</PagerTemplate>

后臺(tái)代碼:
復(fù)制代碼 代碼如下:
//分頁
protected void GridViewHistory_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridViewHistory.PageIndex = e.NewPageIndex;
dataBinding();
}
protected void Button_search_Click(object sender, EventArgs e)
{
dataBinding();
}
protected void lb_firstpage_Click(object sender, EventArgs e)
{
this.GridViewHistory.PageIndex = 0;
dataBinding();
}
protected void lb_previouspage_Click(object sender, EventArgs e)
{
if (this.GridViewHistory.PageIndex > 0)
{
this.GridViewHistory.PageIndex--;
dataBinding();
}
}
protected void lb_nextpage_Click(object sender, EventArgs e)
{
if (this.GridViewHistory.PageIndex < this.GridViewHistory.PageCount)
{
this.GridViewHistory.PageIndex++;
dataBinding();
}
}
protected void lb_lastpage_Click(object sender, EventArgs e)
{
this.GridViewHistory.PageIndex = this.GridViewHistory.PageCount;
dataBinding();
}
dataBinding()為GridViewHistory的數(shù)據(jù)源綁定事件
您可能感興趣的文章:
- AspNetPager+GridView實(shí)現(xiàn)分頁的實(shí)例代碼
- asp.net中g(shù)ridview的查詢、分頁、編輯更新、刪除的實(shí)例代碼
- GridView高效分頁和搜索功能的實(shí)現(xiàn)代碼
- .net GridView分頁模板的實(shí)例代碼
- asp.net中讓Repeater和GridView支持DataPager分頁
- jquery+ashx無刷新GridView數(shù)據(jù)顯示插件(實(shí)現(xiàn)分頁、排序、過濾功能)
- 利用jQuery 實(shí)現(xiàn)GridView異步排序、分頁的代碼
- GridView自定義分頁的四種存儲(chǔ)過程
- ASP.Net2.0 GridView 多列排序,顯示排序圖標(biāo),分頁
- GridView分頁的實(shí)現(xiàn)(通用分頁模板)
相關(guān)文章
.net indexOf(String.indexOf 方法)
字符串的IndexOf()方法搜索在該字符串上是否出現(xiàn)了作為參數(shù)傳遞的字符串,如果找到字符串,則返回字符的起始位置 (0表示第一個(gè)字符,1表示第二個(gè)字符依此類推)如果說沒有找到則返回 -12012-10-10
.net重啟iis線程池和iis站點(diǎn)程序代碼分享
服務(wù)器監(jiān)控,一定時(shí)間內(nèi)或者iis異常就需要重啟線程池和站點(diǎn),下面我們用代碼來做這個(gè)功能2013-12-12
asp.net 模擬提交有文件上傳的表單(通過http模擬上傳文件)
通過HTTP模擬GET或POST請求,提交數(shù)據(jù)到服務(wù)端獲取響應(yīng),比較常見些;但如上傳文件到服務(wù)端,使用html form當(dāng)然簡單了,而因環(huán)境所限有時(shí)需要使用模擬方法去提交有附件(文件上傳)的表單。2010-02-02
Log4net在.Net?Winform項(xiàng)目中的使用實(shí)例詳解
Log4net是一個(gè)流行的日志記錄工具,可以幫助開發(fā)人員在應(yīng)用程序中實(shí)現(xiàn)高效的日志記錄,本文將提供一個(gè)詳細(xì)的分步驟示例,來幫助您在.Net Winform項(xiàng)目中使用Log4net,感興趣的朋友一起看看吧2023-08-08
ASP.NET?Core?MVC中使用Tag?Helper組件
這篇文章介紹了ASP.NET?Core?MVC中使用Tag?Helper組件的方法,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-02-02
ASP.NET?MVC使用typeahead.js實(shí)現(xiàn)輸入智能提示功能
這篇文章介紹了ASP.NET?MVC使用typeahead.js實(shí)現(xiàn)輸入智能提示功能的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-09-09

