I want to change the color of the background of an item in datalist
upon some condition while binding the data? How?
Add a ItemDataBound
event handler to the datalist
ASPX:
<asp:DataList ID="DataList1" runat="server"
onitemdatabound="DataList1_ItemDataBound">
</asp:DataList>
Code Behind:
Protected Sub DataList1_ItemDataBound(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
' check condition and change styles
End If
End Sub