在DataGrid中怎么样把鼠标放到某一行,那行就焦点显示?
并可以选中。

解决方案 »

  1.   

    参考     private void dataGrid_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
          {
             if ( ( e.Item.ItemType == ListItemType.Item ) || ( e.Item.ItemType == ListItemType.AlternatingItem ) || ( e.Item.ItemType == ListItemType.SelectedItem ) )
             {
                e.Item.Attributes.Add( "OnMouseOver", "this.style.backgroundColor = '#BED3E9';this.style.cursor='hand'");
                e.Item.Attributes.Add( "OnMouseOut", "this.style.backgroundColor='white';");
             }
          }
      

  2.   

    griddatabind中写
    if(e.Item.ItemIndex >= 0)
    {
    e.Item.Attributes["onmouseover"] = "this.name=this.style.backgroundColor;this.style.backgroundColor='#cccccc'";
    e.Item.Attributes["onmouseout"] = "this.style.backgroundColor=this.name;";
    }