- C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); e.Row.Attributes.Add("onmouseout", "this.style.backrgoundColor=currentcolor;"); //e.Row.Cells[3].Text = (Convert.ToSingle(e.Row.Cells[3].Text)).ToString("F2"); //e.Row.Cells[3].Text = string.Format("{0:F2}", Convert.ToDouble(e.Row.Cells[3].Text)); }
这个可以实现 高亮
但是有一个问题, 你在移动到其他行的时候, 其他行也亮,但是前一行 也亮 没有变回原来的原色。 麻烦告知原因 谢谢
------解决方案--------------------------------------------------------
- C# code
e.Row.Attributes["onmouseover"] = "e=this.style.backgroundColor;this.style.backgroundColor='#6699ff'";e.Row.Attributes["onmouseout"] = "this.style.backgroundColor=e";
------解决方案--------------------------------------------------------
refer:
http://www.cnblogs.com/insus/articles/1411057
http://www.cnblogs.com/insus/archive/2011/06/25/2090071
http://www.cnblogs.com/insus/archive/2011/10/17/2215637