ASP.NET基础教程-DataGrid表格控件-利用ItemDataBound事件实现鼠标移动到控件的某一行时改变该行的背景色

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");
 }
}

你可能感兴趣的:(asp.net,基础教程,DataGrid表格控件,ItemDataBound事件)