您的位置:首页 > 编程语言 > ASP

ASP.NET中GridView单击一行变色并可互斥代码[测试有效!!]

2009-10-15 15:28 507 查看
在RowDataBound中

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "ItemOver(this)");
}

js代码加在头和身体之间
<script language="javascript" type="text/javascript">
if (!objbeforeItem)
{
var objbeforeItem=null;
var objbeforeItembackgroundColor=null;
}
function ItemOver(obj)
{
if(objbeforeItem)
{
objbeforeItem.style.backgroundColor = objbeforeItembackgroundColor;
}
objbeforeItembackgroundColor = obj.style.backgroundColor;
objbeforeItem = obj;
obj.style.backgroundColor = "#FFFF00";
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐