[已解决问题] 关于GridView 中当前行中变色!苦闷了好久啊!
提问时间: 2008-03-12 14:32
悬赏分:20 浏览:422 次

 当鼠标放在GridView的某一行时变色,离开是是有变色,好象在DataBinding事件中写什么...

请大哥们举个简单的例子!先谢谢!


提问者:HamunNet - 初学一级
最佳答案
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
if (e.Row.RowIndex != -1)
        {
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#E2F2FF'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
        }
    }
2008/3/12 16:15:24 回答者:AndyFish


提问者对于答案的评价:xiexie
其它回答(5)
在模板中加 onmouseover =“”
onmouseleave=“”
3个月前   回答者:Wilensky - 小虾三级
在事件中指定每一行的onmouseover
onmouseout事件,在事件中通过js代码改变颜色
如:
e.Row.Attributes.Add("onmouseover",
      "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#D1E9F1'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");


3个月前   回答者:张荣华 - 小虾三级
GridView1_RowDataBound事件中写入楼上的代码就可以了.
3个月前   回答者:侯垒 - 小虾三级
三楼正解
3个月前   回答者:oec2003 - 小虾三级
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {              
            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.originalcolor=this.style.backgroundColor; this.style.backgroundColor='Silver';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");    
    }
3个月前   回答者:小孤狸 - 初学一级
评论
3个月前   HamunNet :
GridView中什么地方?
我是个新新手,对GridView还不熟悉!我还是不懂 麻烦您啊!
   您需要登录以后才能回答!
我的问题    我要提问


快到期问题

> 问题排行榜

有不合适内容,建议去除