GridView 隔行变色以及高亮显示当前行

<%@ Page Language="VB" AutoEventWireup="false" ViewStateMode="Disabled" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        th
        {
            background-color:#96E1A0; 
        }
        td
        {
            background-color:#D4F8D4;
            border:1px solid #838282;
        }
        .evenTd
        {
            background-color:#D4F8F5;
        }
        .oddTd
        {
            background-color:#D4F8E3;    
        }
        .trHover
        {
            background-color:Green;
        }
        .trSelected
        {
            background-color:Blue;
        }

    </style>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('tr').hover(function () {
                $(this).children('td').addClass('trHover');
            }, function () {
                $(this).children('td').removeClass('trHover');
            });
            $('tr:even').children('td').addClass('evenTd');
            $('tr:odd').children('td').addClass('oddTd');
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="au_id" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="au_id" HeaderText="au_id" ReadOnly="True" 
                    SortExpression="au_id" />
                <asp:BoundField DataField="au_lname" HeaderText="au_lname" 
                    SortExpression="au_lname" />
                <asp:BoundField DataField="au_fname" HeaderText="au_fname" 
                    SortExpression="au_fname" />
                <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />
                <asp:BoundField DataField="address" HeaderText="address" 
                    SortExpression="address" />
                <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
                <asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />
                <asp:BoundField DataField="zip" HeaderText="zip" SortExpression="zip" />
                <asp:CheckBoxField DataField="contract" HeaderText="contract" 
                    SortExpression="contract" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:F:\ACCP6\WEBTEST\APP_DATA\PUBS.MDFConnectionString %>" 
            SelectCommand="SELECT * FROM [authors]"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

知识共享许可协议
《GridView 隔行变色以及高亮显示当前行》常伟华 创作。
采用 知识共享 署名-相同方式共享 3.0 中国大陆 许可协议进行许可。
  • 多说评论
  • 签名
  • 新浪微博
  • 默认评论
  • Tab Header 5

0 条评论 / 点击此处发表评论

Tab Content 5

开发技术


开发平台和工具

sitemap     151.13ms