D
DavidC
I have an asp.net listView that I want to change the background color based
on a condition. I have started to do something in the ItemDataBound event
but cannot find out what method or ??? to use to assign a background color.
I have done this in a GridView but this is the first I have tried in
ListView. Below is my code if someone can help. Thanks.
Protected Sub lvPTODetails_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.ListViewItemEventArgs) Handles
lvPTODetails.ItemDataBound
Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)
' Retrieve the Vendor value for the current item.
Dim dblAvailable As Double =
Convert.ToDouble(rowView("UnitsAvailable"))
If dblAvailable <> 0 Then
'do something here to change background color
End If
End Sub
on a condition. I have started to do something in the ItemDataBound event
but cannot find out what method or ??? to use to assign a background color.
I have done this in a GridView but this is the first I have tried in
ListView. Below is my code if someone can help. Thanks.
Protected Sub lvPTODetails_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.ListViewItemEventArgs) Handles
lvPTODetails.ItemDataBound
Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)
' Retrieve the Vendor value for the current item.
Dim dblAvailable As Double =
Convert.ToDouble(rowView("UnitsAvailable"))
If dblAvailable <> 0 Then
'do something here to change background color
End If
End Sub