首页 新闻 会员 周边

关于GridView 中当前行中变色!苦闷了好久啊!

0
悬赏园豆:20 [已解决问题] 解决于 2008-04-17 10:15
<P>&nbsp;当鼠标放在GridView的某一行时变色,离开是是有变色,好象在DataBinding事件中写什么...</P> <P>请大哥们举个简单的例子!先谢谢!</P>
HamunNet的主页 HamunNet | 初学一级 | 园豆:25
提问于:2008-03-12 14:32
< >
分享
最佳答案
0
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"); } }
AndyFish | 小虾三级 |园豆:1575 | 2008-03-12 16:15
其他回答(5)
0
在模板中加 onmouseover =“” onmouseleave=“”
niugm | 园豆:1685 (小虾三级) | 2008-03-12 14:40
0
在事件中指定每一行的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");
张荣华 | 园豆:2020 (老鸟四级) | 2008-03-12 15:53
0
GridView1_RowDataBound事件中写入楼上的代码就可以了.
侯垒 | 园豆:3435 (老鸟四级) | 2008-03-13 15:40
0
三楼正解
oec2003 | 园豆:945 (小虾三级) | 2008-03-14 08:45
0
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;"); }
小孤狸 | 园豆:7 (初学一级) | 2008-03-20 18:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册