日期:2014-05-19  浏览次数:20461 次

如何实现鼠标指向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 '; ");
}
}