DataGrid实现鼠标放到某行改变背景色

private   void  DataGrid_ItemDataBound( object  sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        
{
            
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            
{
                e.Item.Attributes.Add(
"onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='Gainsboro'");
                e.Item.Attributes.Add(
"onmouseout""this.style.backgroundColor=this.oldcolor");
                
for (int i=0;i<GridAdSite.Columns.Count;i++)
                
{
                    e.Item.Cells[i].Attributes.Add(
"onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='OldLace'");
                    e.Item.Cells[i].Attributes.Add(
"onmouseout""this.style.backgroundColor=this.oldcolor");
                }


            }


        }
 

你可能感兴趣的:(datagrid,object)