protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("OnClick", "this.style.backgroundColor='Red'");
        }
    }被单击的数据 显示高亮单击另一条数据时  原来显示高亮的恢复原来的颜色.怎样实现?

解决方案 »

  1.   

    失去焦点事件:
    e.Row.Attributes.Add("onblur", "this.style.backgroundColor='???'"); 其他鼠标事件:
    onmousedown 当用户用任何鼠标按钮单击对象时触发。onmouseenter 当用户将鼠标指针移动到对象内时触发。onmouseleave 当用户将鼠标指针移出对象边界时触发。onmousemove 当用户将鼠标划过对象时触发。onmouseout 当用户将鼠标指针移出对象边界时触发。onmouseover 当用户将鼠标指针移动到对象内时触发。onmouseup 当用户在鼠标位于对象之上时释放鼠标按钮时触发。onmousewheel 当鼠标滚轮按钮旋转时触发。onmove 当对象移动时触发。onmoveend 当对象停止移动时触发。onmovestart 当对象开始移动时触发。试试
      

  2.   

    protected void gvItem_RowCreated(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes["style"] = "Cursor:hand "; //鼠标变成手
                    e.Row.Attributes.Add("onmouseover ", "currentcolor=this.style.backgroundColor;this.style.backgroundColor= '#C0C0FF ';this.style.cursor= 'hand '; ");
                    //当鼠标移走时还原该行的背景色
                    e.Row.Attributes.Add("onmouseout ", "this.style.backgroundColor=currentcolor ");
                    //选择任意处都选择 
                    e.Row.Attributes.Add("onclick", "javascirpt:__doPostBack('gvItem','Select$" + e.Row.RowIndex + "')");
                }   
            }
      

  3.   

    写一个鼠标移进事件。。改className
    和鼠标移出事进 改className回来
      

  4.   

    JS我不会用, 能写个例子吗?
    我需要的是单击时间  OnMouseOut和OnMouseOver效果不好
      

  5.   

    这样应该可以,onmouseout就行了
      

  6.   

    失去焦点事件: 
    e.Row.Attributes.Add("onblur", "this.style.backgroundColor=''"); //空值就是原来的底色e.Row.Attributes.Add("OnClick", "this.style.backgroundColor='Red'"); 
      

  7.   

    e.Row.Attributes.Add("OnClick", "row_click(this)");JS:
    var lastRow="";
    function row_click(row)
    {
    row.style.backgroundColor='Red';
    if(lastRow !="")
    {
    lastRow.style.backgroundColor=''; 
    }
    lastRow = row;
    }
    这样也肯定OK!
      

  8.   

    e.Row.Attributes.Add("onblur", "this.style.backgroundColor=''"); 
    这个事件 怎样才能触发,我选择另外一条数据 触发不了
      

  9.   

    e.Row.Attributes.Add("onblur", "this.style.backgroundColor=''"); 
    这个事件 怎样才能触发,我选择另外一条数据 触发不了
    求救啊