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";
    }
    }

  • 相关阅读:
    回答自己之前的提问!
    阅读《构建之法》第13-17章
    阅读《构建之发》10-12章
    阅读《构建之法 》8,9,10章
    Practise 5.2测试与封装(黑白盒
    Practice5.1 测试与封装5.1
    Practice4 阅读《构建之法》6-7章
    Practice3 阅读《构建之法》1-5章
    “做汉堡”之评价我的队友
    Practice2 结对子之“小学四则运算”
  • 原文地址:https://www.cnblogs.com/ypfnet/p/3629092.html
Copyright © 2011-2022 走看看