zoukankan      html  css  js  c++  java
  • Gridview鼠标移动到数据行时改变该数据行的背景色

    方法一
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    //设置鼠标覆盖时数据行的背景色
    e.Row.Attributes.Add("onmouseover","this.style.backgroundColor='green'");
    //设置鼠标离开该数据行时数据行的背景色,即还原数据行背景色
    e.Row.Attributes.Add("onmouseout","this.style.background='#ffffff'");
    //设置鼠标覆盖数据行时鼠标样式
    e.Row.Attributes["style"] = "Cursor:pointer";
    }
    }
    方法二:此方法的好处是不会修改原来的所有行背景色!
    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='green'");
    //设置鼠标离开该数据行时数据行的背景色,即还原数据行背景色
    e.Row.Attributes.Add("onmouseout","this.style.background=c);
    //设置鼠标覆盖数据行时鼠标样式
    e.Row.Attributes["style"] = "Cursor:pointer";
    }
    }

  • 相关阅读:
    jQuery代码优化的9种方法
    关于javascript代码优化的8点建议
    javascript编码标准
    前端学算法之算法复杂度
    前端学算法之算法模式
    前端学算法之搜索算法
    前端学算法之排序算法
    前端学数据结构之图
    前端学数据结构之树
    前端学数据结构之字典和散列表
  • 原文地址:https://www.cnblogs.com/ypfnet/p/3629092.html
Copyright © 2011-2022 走看看