gridview分页显示_html分页显示数据

gridview分页显示_html分页显示数据首先把CSS样式代码粘贴过来:.gv{   border:1pxsolid#D7D7D7;   font-size:12px;   text-align:center;}.gvHeader{   color:#3F6293;   background-color:#F7F7F7;   height:24px;   line-height:24px;   tex

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

首先把CSS样式代码粘贴过来:

.gv
{

    border: 1px solid #D7D7D7;
    font-size:12px;
    text-align:center;
}
.gvHeader
{

    color: #3F6293;
    background-color: #F7F7F7;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-weight: normal;
    font-variant: normal;
}
.gvHeader th
{

    font-weight: normal;
    font-variant: normal;
}
.gvRow, .gvAlternatingRow, .gvEditRow
{

    line-height: 20px;
    text-align: center;
    padding: 2px;
    height: 20px;
}
.gvAlternatingRow
{

    background-color: #F5FBFF;
}
.gvEditRow
{

    background-color: #FAF9DD;
}
.gvEditRow input
{

    background-color: #FFFFFF;
    width: 80px;
}
.gvEditRow .gvOrderId input, .gvEditRow .gvOrderId
{

    width: 30px;
}
.gvEditRow .checkBox input, .gvEditRow .checkBox
{

    width: auto;
}
.gvCommandField
{

    text-align: center;
    width: 130px;
}

.gvLeftField
{

    text-align: left;
    padding-left: 10px;
}
.gvBtAField
{

    text-align: center;
    width: 130px;
}
.gvCommandField input
{

    background-image: url(../Images/gvCommandFieldABg.jpg);
    background-repeat: no-repeat;
    line-height: 23px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    width: 50px;
    height: 23px;
    margin-right: 3px;
    margin-left: 3px;
    text-indent: 10px;
}
.gvPage
{

    padding-left: 15px;
    font-size: 18px;
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
}
.gvPage a
{

    display: block;
    text-decoration: none;
    padding-top: 2px;
    padding-right: 5px;
    padding-bottom: 2px;
    padding-left: 5px;
    border: 1px solid #FFFFFF;
    float: left;
    font-size: 12px;
    font-weight: normal;
}
.gvPage a:hover
{

    display: block;
    text-decoration: none;
    border: 1px solid #CCCCCC;
}

根据上面列出的CSS样式样式名称,将他们分别加入网页GridView的不同标记中,举例如下:

<RowStyle BackColor=”#E7E7FF” ForeColor=”#4A3C8C” CssClass=”gvRow” />
<HeaderStyle BackColor=”#4A3C8C” Font-Bold=”True” ForeColor=”#F7F7F7″ CssClass=”gvHeader” />
<AlternatingRowStyle BackColor=”#F7F7F7″ CssClass=”gvAlternatingRow” />

使用改样时候的gridView效果如下所示:

gridview分页显示_html分页显示数据

 

其中gridview下方的换页代码为:

<PagerTemplate>
    <table width=”100%” style=”font-size:12px;”>
        <tr>
        <td style=”text-align: right”>
            第<asp:Label ID=”lblPageIndex” runat=”server” Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>’></asp:Label>页
            /共<asp:Label ID=”lblPageCount” runat=”server” Text='<%# ((GridView)Container.Parent.Parent).PageCount %>’></asp:Label>页&nbsp;&nbsp;
            <asp:LinkButton ID=”btnFirst” runat=”server” CausesValidation=”False”
                CommandName=”Page” Text=”首页” CommandArgument=”first” OnClick=”btnFirst_Click”>
            </asp:LinkButton>
            <asp:LinkButton ID=”btnPrev” runat=”server” CausesValidation=”False”
                CommandName=”Page” Text=”上一页” CommandArgument=”prev” οnclick=”btnFirst_Click”>
            </asp:LinkButton>
            <asp:LinkButton ID=”btnNext” runat=”server” CausesValidation=”False”
                CommandName=”Page” Text=”下一页” CommandArgument=”next” OnClick=”btnFirst_Click”>
            </asp:LinkButton>
            <asp:LinkButton ID=”btnLast” runat=”server” CausesValidation=”False”
                CommandName=”Page” Text=”尾页” CommandArgument=”last” OnClick=”btnFirst_Click”>
            </asp:LinkButton>
            <asp:TextBox ID=”txtNewPageIndex” runat=”server” Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>’
                Width=”20px” AutoPostBack=”True” 
                ontextchanged=”txtNewPageIndex_TextChanged”></asp:TextBox>
            <asp:LinkButton ID=”btnGo” runat=”server” CausesValidation=”False” CommandArgument=”go”
                CommandName=”Page” Text=”GO” OnClick=”btnFirst_Click”></asp:LinkButton>
        </td>
        </tr>
    </table>
</PagerTemplate>

方法btnFirst_Click的定义如下所示:

protected void btnFirst_Click(object sender, EventArgs e)
{

    switch (((LinkButton)sender).CommandArgument.ToString())
    {

        case “first”:
            GridViewAmusement.PageIndex = 0;
            break;
        case “last”:
            GridViewAmusement.PageIndex = GridViewAmusement.PageCount – 1;
            break;
        case “prev”:
            GridViewAmusement.PageIndex = GridViewAmusement.PageIndex – 1;
            break;
        case “next”:
            GridViewAmusement.PageIndex = GridViewAmusement.PageIndex + 1;
            break;
        case “go”:
            {

                GridViewRow gvr = GridViewAmusement.BottomPagerRow;
                TextBox temp = (TextBox)gvr.FindControl(“txtNewPageIndex”);
                int res = Convert.ToInt32(temp.Text.ToString());
                GridViewAmusement.PageIndex = res – 1;
            }
            break;
    }
    BindData();//根据需要重新绑定数据源至GridView控件。
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/193349.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python基础几大数据类型

    python基础几大数据类型数据类型1.数据类型之整型int大白话理解:整数int作用:记录人的年龄班级人数…定义:都是整数age=18直接写整数就是整型2.数据类型之浮点型float大白话理解:

    2022年7月5日
    19
  • oracle导出dmp文件失败_oracle导出数据库dmp文件

    oracle导出dmp文件失败_oracle导出数据库dmp文件–创建用户createuseranhuiidentifiedbyanhui-给予用户权限grantcreatesessiontoanhuigrantconnect,resourcetoanhui;-创建表空间1)先导dmp文件,报错:tablespace‘FMIS_LOB’doesnotexist2)然后创建表空间createtablespaceFMIS_LOB…

    2022年8月30日
    3
  • Navicat Premium 常用功能讲解

    Navicat Premium 常用功能讲解

    2021年11月9日
    59
  • TFS2010中文版安装「建议收藏」

    TFS2010中文版安装「建议收藏」 VS2010的中文版出来一段时间了,对TFS2010的了解,也有一段时间了,只不过中文版还是首次见到。于是把第一次安装的图片分享出来,公供参数。TFS2010安装环境是操作系统为WindowsServer2003SP2(X86),WindowsServer2003R2(X86),WindowsServer2003R2SP2(X86),WindowsServer200…

    2022年9月23日
    1
  • 使用 SSH 连接到 Linux 实例

    使用 SSH 连接到 Linux 实例

    2022年2月15日
    61
  • LTE学习-信道估计(LS算法)

    LTE学习-信道估计(LS算法)无线环境数复杂多变的 信号在传播过程中就会受到各种各样的干扰 到达接收端时 信号的幅度 相位和频率都会发生很大的改变 而信道估计和信道均衡的作用就是尽可能恢复出信号 因此 一个良好的估计和均衡算法对于接收端的性能来说至关重要 决定了信号最终的解出率 根据是否借助导频信息 可以将信道估计分为盲估计 半盲估计和非盲信道估计三种 盲信道估计无需借助导频符号 也不占用频谱资源 只利用接收信号本身固有的

    2025年8月6日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号