那浓雾,抓一把,软绵绵;吸一口,甜津津;踩一脚,轻悠悠。既然都是风景,何必纠结与下不去的站,互不干扰,各自安好。
<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的数据源绑定事件
到此这篇关于GridView分页代码简单万能实用就介绍到这了。前有阻碍,奋力把它冲开,运用炙热的激情,转动心中的期待,血在澎湃,吃苦流汗算什么。更多相关GridView分页代码简单万能实用内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!