protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
        {               
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                   
                        //当鼠标停留时更改背景色
                        // e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
                        //当鼠标移开时还原背景色
                        //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
                        //鼠标移出时,行背景色变 
                        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
                   
                }
           
        }

解决方案 »

  1.   

    2种实现方法
    http://dotnet.aspx.cc/file/Change-Gridview-Row-Background-When-mouseover.aspx你的代码应该可以你设置样式代码怎么写的?
      

  2.   

      <asp:GridView ID="gvKaiHao" 
            class="table" runat="server" AutoGenerateColumns="False"
                                                    DataKeyNames="KaiHaoID"
                                                    onrowcommand="gvKaiHao_RowCommand" 
            width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" 
            onrowdatabound="gvKaiHao_RowDataBound">
                                                    <Columns>
                                                                                                           <asp:TemplateField  ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff"  ItemStyle-Height="30" HeaderStyle-Height="30">
                                                            <HeaderTemplate>
                                                                手机号码
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <%# Eval("Phone") %>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="RName" HeaderText="R类型"  ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff"  ItemStyle-Height="30" HeaderStyle-Height="30" ItemStyle-ForeColor="Red"/>
                                                        <asp:BoundField DataField="DepartmentName" HeaderText="部门"  ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff"  ItemStyle-Height="30" HeaderStyle-Height="30"/>
      </Columns>
                                                                                        </asp:GridView>
    就类似这样的
      

  3.   

    protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //鼠标移动颜色
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;style.backgroundColor='#add8e6'");
                e.Row.Attributes.Add("onmouseout", "style.backgroundColor=c");
                //设置悬浮鼠标指针形状为"小手"
                e.Row.Attributes["style"] = "Cursor:hand";        }
        }