时间:2021-07-01 10:21:17 帮助过:29人阅读
- <br><asp:GridView ID="GridViewHistory" runat="server" AutoGenerateColumns="False" <br>CssClass="vip_table" GridLines="None" BorderStyle="None" CellPadding="0" <br>ShowHeader="False" AllowPaging="true" PageSize="20" <br>onpageindexchanging="GridViewHistory_PageIndexChanging"> <br><PagerTemplate> <br><asp:LinkButton ID="lb_firstpage" runat="server" onclick="lb_firstpage_Click">首页</asp:LinkButton> <br><asp:LinkButton ID="lb_previouspage" runat="server" <br>onclick="lb_previouspage_Click">上一页</asp:LinkButton> <br><asp:LinkButton ID="lb_nextpage" runat="server" onclick="lb_nextpage_Click">下一页</asp:LinkButton> <br><asp:LinkButton ID="lb_lastpage" runat="server" onclick="lb_lastpage_Click">尾页</asp:LinkButton> <br>第<asp:Label ID="lbl_nowpage" runat="server" Text="<%#GridViewHistory.PageIndex+1 %>" ForeColor="#db530f"></asp:Label>页/共<asp:Label <br>ID="lbl_totalpage" runat="server" Text="<%#GridViewHistory.PageCount %>" ForeColor="#db530f"></asp:Label>页 <br></PagerTemplate> <br> <br><img src="https://img.gxlcms.com//Uploads-s/new/2019-09-19-201919/2012122894438679.png"><br>后台代码: <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br>//分页 <br>protected void GridViewHistory_PageIndexChanging(object sender, GridViewPageEventArgs e) <br>{ <br>GridViewHistory.PageIndex = e.NewPageIndex; <br>dataBinding(); <br>} <br>protected void Button_search_Click(object sender, EventArgs e) <br>{ <br>dataBinding(); <br>} <br>protected void lb_firstpage_Click(object sender, EventArgs e) <br>{ <br>this.GridViewHistory.PageIndex = 0; <br>dataBinding(); <br>} <br>protected void lb_previouspage_Click(object sender, EventArgs e) <br>{ <br>if (this.GridViewHistory.PageIndex > 0) <br>{ <br>this.GridViewHistory.PageIndex--; <br>dataBinding(); <br>} <br>} <br>protected void lb_nextpage_Click(object sender, EventArgs e) <br>{ <br>if (this.GridViewHistory.PageIndex < this.GridViewHistory.PageCount) <br>{ <br>this.GridViewHistory.PageIndex++; <br>dataBinding(); <br>} <br>} <br>protected void lb_lastpage_Click(object sender, EventArgs e) <br>{ <br>this.GridViewHistory.PageIndex = this.GridViewHistory.PageCount; <br>dataBinding(); <br>} <br> <br>dataBinding()为GridViewHistory的数据源绑定事件</li><li> </li><li> </li></ol></pre>