GridView,一张数据比较多的表格,满面的数据,容易花眼呀。给GridView的行增加个鼠标事件,鼠标所在行的背景色会变,这样就好看多了吧!
这功能实现起来也很简单,在GridView的RowDataBound事件中写:
if
(e.Row.RowType
==
DataControlRowType.DataRow)
... {
e.Row.Attributes["onmouseover"] = "javascript:this.style.background="Red";
e.Row.Attributes["onmouseout"] = "javascript:this.style.background=''White";
}
... {
e.Row.Attributes["onmouseover"] = "javascript:this.style.background="Red";
e.Row.Attributes["onmouseout"] = "javascript:this.style.background=''White";
}
这样行就随这鼠标变色啦!