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");
}
}
}
本文介绍如何使用ASP.NET中的DataGrid控件实现当鼠标悬停在表格项上时背景颜色发生变化的效果,并对每一个单元格设置相似的鼠标悬停样式。
874

被折叠的 条评论
为什么被折叠?



