gridview ,鼠标,行变色

在gridview中添加事件OnRowDataBound="GridViewUserInfo_OnRowDataBound"

在后台中添加该事件的方法体:

protected void GridViewUserInfo_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)

e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");

e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");

}
} 每行都添加了js方法:


var _oldColor;

function SetNewColor(source)
{

_oldColor=source.style.backgroundColor;

source.style.backgroundColor='#deeff9';
 
}

function SetOldColor(source)
{
source.style.backgroundColor=_oldColor;
} 颜色根据自己的需要变换。

posted @ 2015-01-21 14:46  小胖是猪  阅读(162)  评论(0)    收藏  举报