百度空间 | 百度首页 
 
查看文章
 
GridView选中行变色[原]
2009年03月24日 星期二 02:48

var prevselitem=null;
//调用示例:在RowDataBound事件中加上如下代码
/*
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");//当鼠标停留时更改背景色
            e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//当鼠标移开时还原背景色
            e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)");
        }

*/
function selectx(row)
{
    if(prevselitem!=null)
     {
         prevselitem.style.backgroundColor='#ffffff';
     }
     row.style.backgroundColor='PeachPuff';
    prevselitem=row;
    var chkColl=row.all;
    for(var i=0;i<chkColl.length;i++)
    {
        if(chkColl[i].type=="checkbox" )
        {//alert(23);
            if( chkColl[i].checked!=true)
            {
                chkColl[i].checked=true;
            }
            else
            {
                chkColl[i].checked=false;
            }
            chkItem_Click(chkColl[i]); //引发CheckBoxGv_list.js中的方法
        }
    }
}


类别:js && html && xml && 正则 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu