我在GridView1_RowDataBound(object sender, GridViewRowEventArgs e)中加了
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='yellow'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
但是鼠标经过没有效果,请问是为什么?

解决方案 »

  1.   

    e.Row.Attributes.Add("OnMouseOver", "c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
         e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor=c");注意大小写区分
      

  2.   

     if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#B7E3FE'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                }
      

  3.   

    瞎说,XHTML中这些事件都是全小写
      

  4.   

       e.Row.Attributes.Add("onmouseover", "this.style.currentcolor=this.style.backgroundColor; this.style.backgroundColor='#ff88cc'; this.style.cursor='pointer';");
                e.Row.Attributes.Add("onmouseout", "this.style.currentcolor=this.style.backgroundColor; this.style.backgroundColor='';");
      

  5.   

    写个JS函数,在GV_RowDataBound事件里这样调用e.Row.Attributes.Add("onclick", "changeRowColor(" + e.Row.RowIndex + ",'" + gvMainList.ClientID + "');");
    function changeRowColor( row,girdview)
       {   
           
           var GridView = document.getElementById(girdview);
           if(GridView!=null)
           {
              //GridView.rows[1].className ="RowStyle";
              for(i = 1;i < GridView.rows.length-1; i++)
              {   
                  if(i==row+1)
                  {
                     GridView.rows[i].className ="SelectedRowStyle";
                   
                  }
                  else 
                  {
                    if(i%2==0)
                    {
                      GridView.rows[i].className ="RowStyleNo";
                    }
                    else
                    {
                      GridView.rows[i].className ="RowStyle";
                    }
                    
                 }
              }
           }
           else
           {
             return false;
           }
       }