protected void gridView_OnRowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#CCCCCC'");
//变量c用与存储鼠标移动在行上时,原来的背景色,然后设置为'#CCCCCC'
e.Row.Attributes.Add("onmouseout", " this.style.backgroundColor=c");
//当鼠标离开时,还原背景色
}
}
本文介绍了一个简单的ASP.NET GridView控件事件处理方法,通过gridView_RowCreated事件实现当鼠标悬停在表格行上时改变其背景颜色,并在鼠标移开时恢复原色的效果。
832

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



