鼠标移到datalist某一行时改变该行的背景色

解决方案 »

  1.   

    <script language="JavaScript">var TbRow = document.getElementById("DataList4");
    if (TbRow != null)
    {
        for (var i=0;i<TbRow.rows.length ;i++ )
        {
            if (TbRow.rows[i].rowIndex%2==1)
            {
                TbRow.rows[i].style.background="#ffffff";
            }
            else
            {
                TbRow.rows[i].style.background="url(img/sepbg-2.gif) repeat-x left bottom";
            }
        }
    }</script>
      

  2.   

    // JScript 文件
    onload= function ()
    {
        var a=document.getElementById("Gvstockodd");
        var len=a.rows.length;
       a.style.backgroundColor="#bfccff";
        for(var i=1;i<len;i++)
        {
            if(i%2)
            {
                a.rows[i].style.backgroundColor="#f4d2ff";
                a.rows[i].onmouseout=function()
                {
                    this.style.backgroundColor="#f4d2ff";
                }
            }
            else
            {
                a.rows[i].onmouseout=function()
                {
                    this.style.backgroundColor="";
                }
            }
            a.rows[i].onmouseover=function()
            {
                this.style.backgroundColor="#2ba2ff";
            }
        }
    }
      

  3.   

    在databindS事件里 为每一行添加个ONMOUSEOVER事件 
      

  4.   

    在databindS事件里 为每一行添加个ONMOUSEOVER事件 
      

  5.   

    在DataList1中添加ItemDataBound事件,
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                i = i + 1;
                if (i > 10&&i <= 20)
                {
                    e.Item.BackColor = System.Drawing.Color.FromName("#ECF4DF");
                }
                if (i >= 20)
                {
                    i = 0;
                }
            }
      

  6.   

     在DataList1中添加ItemDataBound事件, 
     e.Item.Attributes.Add("onMouseOver", "javascript:bgcolor=this.style.backgroundColor;this.style.backgroundColor='#ffd700';");
        e.Item.Add("onmouseout", "javascript:this.style.backgroundColor=bgcolor;");
      

  7.   

    嗯. 楼上的都可以.
    还可以用Attributee.Item[i].Attributes["onmouseover"] = "this.style.backgroundColor='#CCFFFF'";  //鼠标悬浮颜色
    e.Item[i].Attributes["onmouseout"] = "this.style.backgroundColor='White'";  //鼠标离开颜色