在RowDataBound的事件里
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#eef7fe'");
// This will be the back ground color of the GridView Control
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#EEEEEE'");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#eef7fe'");
// This will be the back ground color of the GridView Control
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#EEEEEE'");
}
本文介绍如何使用ASP.NET中的GridView控件实现鼠标悬停时更改背景颜色的效果。通过在RowDataBound事件中添加JavaScript代码,可以轻松为GridView中的每一行设置mouseover和mouseout事件,从而实现美观的交互效果。

511

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



