private void DataGrid_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",
"currentcolor=this.style.backgroundColor,this.style.backgroundColor='#ffff00'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
{
if(e.Item.ItemType==ListItemType.Item ||
e.Item.ItemType ==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover",
"currentcolor=this.style.backgroundColor,this.style.backgroundColor='#ffff00'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
}
}
}
转载于:https://blog.51cto.com/chenxing/45634