鼠标移动到GRIDVIEW单元格上执行操作

来源:百度知道 编辑:UC知道 时间:2024/06/09 05:21:13
如题。。。

单元格?现在以Gridview的每一行的第一列为 目标;我现在写个简单的事例,就是当鼠标扫过这个单元格的时候 背景色变为蓝色,鼠标离开后颜色还原。
如下:
GridView1的RowDataBound事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
e.Row.Cells[0].Attributes.Add("onmouseover", " c = this.style.backgroundColor;this.style.backgroundColor='Blue'");
e.Row.Cells[0].Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}