在GridView的相应事件下添加代码实现通过对Javascript鼠标事件onmouseover与onmouseout来实现鼠标滑过时改变背景颜色,代码如下:
protected void GVYWZhuangBeiCategory_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//高亮显示指定行
e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#FFF000'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
}
}