首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么实现鼠标指向GridView控件的行时,该行改变颜色,离开该行时又恢复原来的颜色?

2012-03-17 
如何实现鼠标指向GridView控件的行时,该行改变颜色,离开该行时又恢复原来的颜色???如何实现鼠标指向GridVi

如何实现鼠标指向GridView控件的行时,该行改变颜色,离开该行时又恢复原来的颜色???
如何实现鼠标指向GridView的行时,该行改变颜色,离开该行时又恢复原来的颜色???这个肯定要用到JavaScript脚本了吗?还是GridView控件本身有此功能???

[解决办法]
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == (DataControlRowState.Selected | DataControlRowState.Normal)) && e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "onmouseover ", "this.style.backgroundColor= '#B1CFF8 ' ");
e.Row.Attributes.Add( "onmouseout ", "this.style.backgroundColor= '#E3EAEB '; ");
}
if ((e.Row.RowState == DataControlRowState.Alternate || e.Row.RowState == (DataControlRowState.Selected | DataControlRowState.Alternate))
&& e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "onmouseover ", "this.style.backgroundColor= '#B1CFF8 ' ");
e.Row.Attributes.Add( "onmouseout ", "this.style.backgroundColor= 'White '; ");
}
}

热点排行