protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
本文介绍了一种使用ASP.NET中GridView控件实现行背景色变化的方法。当鼠标悬停在GridView的某一行上时,该行背景色会变为蓝色;当鼠标移开时,背景色将恢复原状。此效果通过直接修改ASP.NET GridView控件的RowDataBound事件来实现。
151

被折叠的 条评论
为什么被折叠?



