在后台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";
}
解决方案 »
- |zyciis| 为什么我的一段HTML的Form放在别人的网站POST过来的数据全是乱码
- IE8传值问题
- .net程序可以用liux服务器吗
- xml的问题。 怎么不能设置InnerText?我写错了么?
- C# 连接数据库问题
- 大家分析一下这个站值多少钱?
- 在MSSQL2000中保存 \\192.168.0.253\电影 这样的数据要用什么数据类型才可以?
- 关于dropdownlist的一个问题
- 能动态的决定输入数据数,就想vb中的datagrid控件一样能一次录入多条数据?急急急!!!!
- 一个简单问题,但我就是想不通,谢谢
- 用户在离开页面后怎样使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