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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 本地apache 可以正常访问,lnmp服务器访问404错误

    本地apache 可以正常访问,lnmp服务器访问404错误

    2021年10月9日
    56
  • nonzero函数_python 类方法

    nonzero函数_python 类方法类的nonzero方法用于将类转换为布尔值。通常在用类进行判断和将类转换成布尔值时调用。比如语句ifA:print'foo'中就会调用A.nonzero()来判断。下面这个程序应

    2022年8月6日
    3
  • pinetwork节点教程_搭建ss教程

    pinetwork节点教程_搭建ss教程文章目录1、简介2、Pi节点安装2.1、操作系统2.2、路由器设置2.3、Docker安装2.4、PiNode安装1、简介    2020年3月31日(太平洋时间)Node软件的测试版上线此,版本号0.015。写下这篇文章时,版本号已更新至0.3.8。Pi节点的安装设置过程稍复杂,在此做个总结。2、Pi节点安装2.1、操作系统2.2、路由器设置2.3、Docker安装2.4、PiNode安装…

    2022年10月8日
    0
  • 基于物品的协同过滤算法:理论说明,代码实现及应用「建议收藏」

    基于物品的协同过滤算法:理论说明,代码实现及应用「建议收藏」基于物品的协同过滤算法:理论说明,代码实现及应用标签:爬虫Python主要参考资料:项亮.推荐系统实践[M].北京:人民邮电出版社,2012.转载请注明出处:sss0.一些碎碎念从4月中旬开始,被导师赶到北京的郊区搬砖去了,根本就没有时间学习看书,这个时候才知道之前的生活是多么的幸福:每天看自己想看的书,然后实践一下,最后写博文总结一下,偶尔还能去跑个步,游个泳。想找实习的计划也泡汤了

    2022年6月26日
    21
  • LayoutParams的详解

    LayoutParams的详解简述:LayoutParams继承于Android.View.ViewGroup.LayoutParams相当于一个Layout的信息包,它封装了Layout的位置、高、宽等信息。假设在屏幕上一块区域是由一个Layout占领的,如果将一个View添加到一个Layout中,最好告诉Layout用户期望的布局方式,也就是将一个认可的layoutParams传递进去。通俗地讲(这里借鉴了网上的一

    2022年4月19日
    43
  • C++生产和使用的临时对象

    C++生产和使用的临时对象

    2022年1月5日
    55

发表回复

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

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