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


相关推荐

  • 关于EnterCriticalSection()(转)「建议收藏」

    关于EnterCriticalSection()(转)「建议收藏」好文章的链接:https://blog.csdn.net/Pro2015/article/details/88786377QF自己的总结:之前一直都会看到EnterCriticalSection

    2022年7月3日
    18
  • 八年phper的高级工程师面试之路八年phper的高级工程师面试之路

    八年phper的高级工程师面试之路八年phper的高级工程师面试之路

    2022年2月15日
    36
  • Fork/Join框架基本使用[通俗易懂]

    1.概述ava.util.concurrent.ForkJoinPool由Java大师DougLea主持编写,它可以将一个大的任务拆分成多个子任务进行并行处理,最后将子任务结果合并成最后的计算结果,并进行输出。本文中对Fork/Join框架的讲解,基于JDK1.8+中的Fork/Join框架实现,参考的Fork/Join框架主要源代码也基于JDK1.8+。这几篇文章将试图解释Fork/…

    2022年4月5日
    45
  • 青蛙过河谁先过_python knn算法实现

    青蛙过河谁先过_python knn算法实现一只青蛙想要过河。 假定河流被等分为若干个单元格,并且在每一个单元格内都有可能放有一块石子(也有可能没有)。 青蛙可以跳上石子,但是不可以跳入水中。给你石子的位置列表 stones(用单元格序号 升序 表示), 请判定青蛙能否成功过河(即能否在最后一步跳至最后一块石子上)。开始时, 青蛙默认已站在第一块石子上,并可以假定它第一步只能跳跃一个单位(即只能从单元格 1 跳至单元格 2 )。如果青蛙上一步跳跃了 k 个单位,那么它接下来的跳跃距离只能选择为 k – 1、k 或 k + 1 个单位。 另请注意

    2022年8月9日
    4
  • 图析:String,StringBuffer与StringBuilder的区别

    图析:String,StringBuffer与StringBuilder的区别一、JavaString类——String字符串常量字符串广泛应用在Java编程中,在Java中字符串属于对象,Java提供了String类来创建和操作字符串。需要注意的是,String的值是不可变的,这就导致每次对String的操作都会生成新的String对象,这样不仅效率低下,而且大量浪费有限的内存空间。我们来看一下这张对String操作时内存变化的图:我们可…

    2022年6月28日
    32
  • ARM的六大类指令集—LDR、LDRB、LDRH、LDM、STR、STRB、STRH、STM

    ARM的六大类指令集—LDR、LDRB、LDRH、LDM、STR、STRB、STRH、STM汇编指令:LDR、LDRB、LDRH、STR、STRB、STRH

    2022年6月16日
    42

发表回复

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

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