GridView光棒效果总结

//方法1 后台代码
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
if (e.Row.RowType == DataControlRowType.DataRow) 
{ 
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFDD7'"); 
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); 
} 
}

方法2,前台代码

 

<tr onclick="test(this)" style="cursor: pointer" onmouseover="currentBgColor=this.style.backgroundColor;this.style.backgroundColor='#cccfff';"
                         onmouseout="this.style.backgroundColor=currentBgColor">

你可能感兴趣的:(GridView光棒效果总结)