Gridview中onmouseover的效果

来源:互联网 发布:新网域名备案号 编辑:程序博客网 时间:2024/04/28 09:20
Gridview中onmouseover的效果
 

在gridview 中,经常会需要一种这样的效果,当鼠标放在某一行时,某一行有一个CSS效果,当鼠标移开该行时,又有另外一个效果,这其实就是利用了onmouseover的效果,实现起来其实很简单,在gridview的
row_databound事件中这样实现就可以了
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='blue'");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");

}

}

 

原创粉丝点击