代码如下
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("OnMouseOver","c=this.style.backgroundColor;this.style.backgroundColor='yellow'");
e.Item.Attributes.Add("OnMouseOut","this.style.backgroundColor=c;");
}
}