在后台DataGrid的DataBound中为前台添加了下列事件,作用是当鼠标点击某行时执行fortry函数,同时让该行变色。但是在点击另一行时原来变色的那行应该恢复原色才行,而下面的代码则是点击了哪几行哪几行就变色。请问如何做到始终只有被点击的行变色?
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onclick","fortry(this);");
e.Item.Attributes.Add("onmousedown", "this.style.backgroundColor='#ccffff';this.style.color='';");
e.Item.ID = "ItemID";
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onclick","fortry(this);");
e.Item.Attributes.Add("onmousedown", "this.style.backgroundColor='#ccffff';this.style.color='';");
e.Item.ID = "ItemID";
}
解决方案 »
- HTML中的换行在浏览器中都解析成一个空格了
- 小小问题。注释不起作用了。在线等结贴。
- 未将对象引用设置到对象的实例。
- 使用NHibernate的朋友,你们是怎样实现数据控件(如Repeater)的嵌套的.
- 用OracleConnection 连接对象向oracle表插入数据 提示ORA-01036: 非法的变量名/编号
- cookie做的系统的退出功能
- [散分啦] 想请教大家一下 关于主从表的问题
- 在使用DataGrid时发生的一个小问题(初学者,请大家帮个忙)
- 用过vs.net2003的兄弟,请告知相对于vs.net2002有哪些改进!老板让我买一套。
- XML请教
- 用户在离开页面后怎样使seesion与cookie 消失?
- iis下载?(不从系统盘安装?)
<tr valign='middle' onMouseOver="this.style.backgroundColor='#EAEAEA';" onMouseOut="this.style.backgroundColor=''">
e.Item.Attributes.Add("onclick","if(this.style.backgroundColor != '#6699ff') {this.style.backgroundColor='#6699ff';} else {this.style.backgroundColor='#ffffff';}") End Sub
If (e.Item.ItemIndex >= 0) Then
e.Item.Attributes("onmouseover") = "this.name=this.style.backgroundColor;this.style.backgroundColor='Honeydew';this.style.color='blue'"
e.Item.Attributes("onmouseout") = "this.style.backgroundColor=this.name;this.style.color='black'"
End If
End Sub