GRID颜色交替。。。。。

<asp:datagrid id="MyDataGrid" runat="server" onitemdatabound="myDataGrid_ItemDataBound" 
 Public Sub myDataGrid_ItemDataBound(ByVal sender As ObjectByVal 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 
原文地址:https://www.cnblogs.com/LCX/p/51733.html