zoukankan      html  css  js  c++  java
  • GridView显示数据鼠标悬停变色

     一、 首先在前台GridView中加上onrowdatabound="GridView1_RowDataBound":

      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                            onrowdatabound="GridView1_RowDataBound">

       .......

     </asp:GridView>

    二、然后在后台的GridView1_RowDataBound事件中写

     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {


                    e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#99FFCC'");     //鼠标悬停变色
                  
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");      //鼠标移走颜色还原
                }
            }

  • 相关阅读:
    java基础测试
    java随笔
    Android 开机广播的使用
    ZOJ 3715 Kindergarten Election
    LightOJ 1051
    LightOJ 1042
    LightOJ 1049
    LightOJ 1048
    LeightOJ 1046
    LightOJ 1045
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/3989097.html
Copyright © 2011-2022 走看看