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='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}
本文介绍了一段 ASP.NET 中实现 GridView 控件鼠标悬停改变背景颜色的效果代码。通过 RowDataBound 事件处理函数,在鼠标移过 GridView 的每一项时更改其背景颜色,并在鼠标移出时恢复原来的背景颜色。

3175

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



