gridview 鼠标经过改变颜色

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
}
}

<script type="text/javascript">
var _oldColor;
function SetNewColor(source)
{
_oldColor=source.style.backgroundColor;
source.style.backgroundColor='#FFFF99';

}
function SetOldColor(source)
{
source.style.backgroundColor=_oldColor;
}

</script>

你可能感兴趣的:(GridView)