读书人

gridview 高亮显示鼠标所在行的有关问

发布时间: 2012-11-04 10:42:42 作者: rapoo

gridview 高亮显示鼠标所在行的问题

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.html
http://www.cnblogs.com/insus/archive/2011/06/25/2090071.html
http://www.cnblogs.com/insus/archive/2011/10/17/2215637.html

读书人网 >asp.net

热点推荐