解决方案 »

  1.   

        写过 但是没放在ModalPopupExtender和panel过··
           protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //加入鼠标滑过的高亮效果
            if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
            {
                //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色
                e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#9999ff',this.style.fontWeight='';");
                //当鼠标离开的时候 将背景颜色还原的以前的颜色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
            }
            //单击行改变行背景颜色
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
            }
        }
      

  2.   

    那就用JS试试看
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)   
        {   
            if (e.Row.RowType == DataControlRowType.DataRow)   
            {   
                e.Row.Attributes["onMouseOver"] = "js.ItemOver(this)";   
            }   
        } 
    页面上加<SCRIPT language=javascript type=text/javascript>   
        var js=new function(){   
        if (!objbeforeItem){var objbeforeItem=null;var objbeforeItembackgroundColor=null;}   
            this.ItemOver=function(obj)   
        {   
            if(objbeforeItem){objbeforeItem.style.backgroundColor = objbeforeItembackgroundColor;}   
            objbeforeItembackgroundColor = obj.style.backgroundColor;   
            objbeforeItem = obj;   
            obj.style.backgroundColor = "#00A9FF";        
        }   
    }   
        </SCRIPT> 或者
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)   
        {   
            if (e.Row.RowType == DataControlRowType.DataRow)   
            {   
                e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");   
                e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");   
            }   
        } 
    页面上加入
    <SCRIPT language=javascript>   
           var _oldColor;   
           function SetNewColor(source)   
           {   
              _oldColor=source.style.backgroundColor;   
              source.style.backgroundColor='#00A9FF;   
           }   
           function SetOldColor(source)   
           {   
             source.style.backgroundColor=_oldColor;   
           }   
        </SCRIPT>
      

  3.   

    我推荐你还是不要用gridview了,它自己生成一堆table代码
      

  4.   

    protected void GridView1_PreRender1(object sender, EventArgs e)
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            //获取表示 GridView 控件中数据行的 GridViewRow 对象的集合。
            //GridViewRowCollection 类用于存储和管理 GridView 控件中的 GridViewRow 对象的集合.
            //一个 GridViewRowCollection,包含 GridView 控件中的所有数据行。
            // GridViewRow的 公共属性 Attributes 
            {
                GridView1.Rows[i].Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFFCC';");            GridView1.Rows[i].Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
            }
        }
      

  5.   

        protected void gvOrder_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmousemove", "movecolor(this)");
                e.Row.Attributes.Add("onmouseout", "outcolor(this)");        }
       }这是这样用的,结果是可以的!
      

  6.   

    估计ModalPopupExtender中用到了鼠标事件,所以你写在控件中的鼠标事件被重置,无效
      

  7.   

    这个可以,我亲自测试过:
    protected void gvDemo_RowDataBound(object sender,  GridViewRowEventArgs e)
    {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
              e.Row.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff' ");     e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
            }
    }
      

  8.   

    //后台
    if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "onmouse(this)");
                e.Row.Attributes.Add("onmouseout", "outmouse(this)");
            }
    //源
         <script language="javascript" type="text/javascript">
            var cru;
            function onmouse(object)
            {
                cru=object.style.backgroundColor;
                object.style.backgroundColor="#ff9900";
            }
            function outmouse(object)
            {
                object.style.backgroundColor=cru;
            }
         </script>
      

  9.   

    单独放在panel里面没有问题的,再加个上那个就没用过了