标签:
第一种:
新建一个js文件 并引用
1 <script src="jquery.js" type="text/javascript"></script>
js文件内容如下:
1 var _oldColor; 2 function SetNewColor(source) 3 { 4 _oldColor=source.style.backgroundColor; 5 6 source.style.backgroundColor=‘#F0F7FD‘; 7 } 8 9 function SetOldColor(source) 10 { 11 source.style.backgroundColor=_oldColor; 12 }
给GridView添加RowDataBound事件
1 protected void DGV_RowDataBound(object sender, GridViewRowEventArgs e) 2 { 3 if (e.Row.RowType == DataControlRowType.DataRow) 4 { 5 e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);"); 6 e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);"); 7 } 8 }
第二种:
1 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 2 { 3 if (e.Row.RowType == DataControlRowType.DataRow) 4 { 5 //高亮显示指定行 6 e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor=‘#FFF000‘"); 7 e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); 8 } 9 }
标签:
原文地址:http://www.cnblogs.com/haibing0107/p/5479034.html