代码改变世界

实现鼠标移到GRIDVIEW控件的某行时改变改行背景颜色

2006-02-21 20:39  Tam  阅读(774)  评论(0编辑  收藏  举报

可以选择GRIDVIEW控件,然后双击RowDataBound事件

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
 //当鼠标移到的时候设置该行颜色为"", 并保存原来的背景颜色
 e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'");
 //当鼠标移走时还原该行的背景色
 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}