<asp:datagrid id="MyDataGrid" runat="server" onitemdatabound="myDataGrid_ItemDataBound"
Public Sub myDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'颜色交替
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#C0C0FF'")
If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'")
End If
If e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'")
End If
End If
End Sub 'DataGrid1_ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'颜色交替
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#C0C0FF'")
If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'")
End If
If e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'")
End If
End If
End Sub 'DataGrid1_ItemDataBound