GridView鼠标移动背景变色,在RowDataBound事件中添加如下代码:

   protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "javascript:c=this.style.backgroundColor;this.style.background='#B0E0E6';");
            e.Row.Attributes.Add("onmouseout", "javascript:this.style.background=c;");
        }
    }

DataGrid鼠标移动背景变色,在ItemDataBound中添加如下代码

    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            e.Item.Attributes["onMouseOver"] = "javascript:c=this.style.backgroundColor;this.style.background='#B0E0E6';";  //current 粉蓝色 //--#6699ff 蓝色 #FFFF00 黄色 #FFFFE0 亮黄色
            e.Item.Attributes["onMouseOut"] = "javascript:this.style.background=c;";
        }
    }

 

 

相关文章:

  • 2021-09-18
  • 2021-12-20
  • 2022-12-23
  • 2022-02-15
  • 2021-11-28
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-18
  • 2021-06-14
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2021-09-11
相关资源
相似解决方案