復(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)(通用分頁模板)