复制代码 代码如下:
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>
后台代码:
复制代码 代码如下:
//分页
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的数据源绑定事件
您可能感兴趣的文章:- AspNetPager+GridView实现分页的实例代码
- asp.net中gridview的查询、分页、编辑更新、删除的实例代码
- GridView高效分页和搜索功能的实现代码
- .net GridView分页模板的实例代码
- asp.net中让Repeater和GridView支持DataPager分页
- jquery+ashx无刷新GridView数据显示插件(实现分页、排序、过滤功能)
- 利用jQuery 实现GridView异步排序、分页的代码
- GridView自定义分页的四种存储过程
- ASP.Net2.0 GridView 多列排序,显示排序图标,分页
- GridView分页的实现(通用分页模板)