来自Asp.net精英论坛:bbs.1aspx.com
在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 language="javascript">
var _oldColor;
function SetNewColor(source)
{
_oldColor=source.style.backgroundColor;
source.style.backgroundColor='#666666';
}
function SetOldColor(source)
{
source.style.backgroundColor=_oldColor;
}
</script>