PC Review


Reply
Thread Tools Rate Thread

Change ListView row background color

 
 
DavidC
Guest
Posts: n/a
 
      22nd Apr 2010
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

--
David
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      25th Apr 2010
On Apr 22, 11:32*pm, DavidC <dlch...@lifetimeinc.com> wrote:
> 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
>
> --
> David


http://www.microsoft.com/communities...&cr=&sloc=&p=1
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
listview item loses background color after I change selection ari Microsoft VB .NET 5 24th Nov 2008 04:56 PM
C# ListView background color question Jason Huang Microsoft C# .NET 1 29th Dec 2006 05:00 AM
Is there a way to get the listview header background color? jrhoads23@hotmail.com Microsoft Dot NET Framework Forms 2 14th Apr 2005 05:47 PM
newbie help in Listview Column BackGround Color VP Microsoft C# .NET 0 9th Mar 2005 12:04 PM
Re: Change background color of particular row in a ListView Peter Foot [MVP] Microsoft Dot NET Compact Framework 0 7th Sep 2003 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:26 AM.