protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判定当前的行是否属于datarow类型的行
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
}
}
ASP.NET2.0下为GridView添加鼠标滑过(onmouseover、onmouseout)的方
最新推荐文章于 2025-11-20 21:02:59 发布
本文介绍如何使用ASP.NET中GridView控件的RowDataBound事件来实现鼠标悬停和点击时改变行背景颜色的功能。通过简单的C#代码片段,实现了当鼠标悬停在GridView的行上时背景变为黄色,鼠标移开后恢复原状,以及点击行时背景变为特定绿色。
1688

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



