代码如下
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;");
}
}
本文介绍了一段 ASP.NET 中用于 DataGrid 的代码,该代码使得 DataGrid 在鼠标悬停时背景颜色发生变化,增强了用户体验。通过 JavaScript 实现了 OnMouseOver 和 OnMouseOut 事件的响应。

1962

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



