Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#D7EEB3'")'鼠标移动时得颜色 e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'")'鼠标离开后的颜色 end if End Sub
http://www.cnblogs.com/webabcd/archive/2007/02/04/639830.html
<tr onmouseover="javascript:this.className='gridview_mouseover';" style="background-color:#DDDDFF;">虽然鼠标事件响应了,但因为后面的style,所以背景色根本不变,不知道怎么办
If e.Row.RowType = DataControlRowType.DataRow Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#D7EEB3'")'鼠标移动时得颜色
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'")'鼠标离开后的颜色
end if
End Sub