zoukankan      html  css  js  c++  java
  • 万能简单GridView分页代码

    <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>

    gridview

    后台代码:

    //分页
        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的数据源绑定事件
  • 相关阅读:
    ubuntu之路——day8.4 Adam自适应矩估计算法
    ubuntu之路——day8.3 RMSprop
    ubuntu之路——day8.2 深度学习优化算法之指数加权平均与偏差修正,以及基于指数加权移动平均法的动量梯度下降法
    ubuntu之路——day8.1 深度学习优化算法之mini-batch梯度下降法
    ubuntu之路——day7.4 梯度爆炸和梯度消失、初始化权重、梯度的数值逼近和梯度检验
    redis作为mysql的缓存服务器(读写分离)
    阿里云服务器上配置并使用: PHP + Redis + Mysql 从配置到使用
    小程序开发测试教程
    使用PHP并发执行任务–curl_multi应用
    PHP返回变量或数组的字符串表示:var_export()
  • 原文地址:https://www.cnblogs.com/wuchao/p/2663993.html
Copyright © 2011-2022 走看看