http://www.csdn.net/Develop/read_article.asp?id=20770

解决方案 »

  1.   

    重写OnItemDataBoundprotected override void OnItemDataBound(System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    e.Item.Attributes["onmouseover"]="this.name=this.style.backgroundColor;this.style.backgroundColor='#FFF79C';"; 
    e.Item.Attributes["onmouseout"]="this.style.backgroundColor=this.name;"; 
    }

    }
      

  2.   

    在DataGrid1_ItemCreated事件中:
    if (e.Item.ItemIndex>=0)
    {
    int i;
    i=e.Item.ItemIndex;
    e.Item.Attributes.Add("onmouseover", "mouseover("+i+")");
                                         e.Item.Attributes.Add("onmouseout", "mouseout("+i+")");

    javascript:
    <script language="JavaScript">
               function mouseover(i)
                 {
                      DataGrid1.rows[i+1].bgColor = "#00C0C0";
                 }
               function mouseout(i)
                 {
                      DataGrid1.rows[i+1].bgColor = "white";
                 }                     

            
    </script>