PC Review


Reply
Thread Tools Rate Thread

how to apply forecolor to listitem of dropdownlist in function of some values?

 
 
Vincent
Guest
Posts: n/a
 
      7th Mar 2008
Hi,

i would like to have a forecolor for each listitem with some values only of
the dropdownlist:

If i=5 ot i=10 or i=15 then apply red forecolor to those listitems otherwise
no color.

For i = 1 To 20
z = New ListItem("item" & i, i)
DropDownList1.Items.Add(z)
??
next

Thanks
Vincent


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      7th Mar 2008
For i = 1 To 20
z = New ListItem("item" & i, i)
If i=5 ot i=10 or i=15 then z.Attributes("style","color:red")
DropDownList1.Items.Add(z)
next

-- bruce (sqlwork.com)


"Vincent" wrote:

> Hi,
>
> i would like to have a forecolor for each listitem with some values only of
> the dropdownlist:
>
> If i=5 ot i=10 or i=15 then apply red forecolor to those listitems otherwise
> no color.
>
> For i = 1 To 20
> z = New ListItem("item" & i, i)
> DropDownList1.Items.Add(z)
> ??
> next
>
> Thanks
> Vincent
>
>
>

 
Reply With Quote
 
Vincent
Guest
Posts: n/a
 
      7th Mar 2008
Hi, thanks but i get the error::
"property access must assign to the property or use its value"


"bruce barker" <(E-Mail Removed)> schreef in bericht
news:E4C9398F-2A49-4703-8817-(E-Mail Removed)...
> For i = 1 To 20
> z = New ListItem("item" & i, i)
> If i=5 ot i=10 or i=15 then z.Attributes("style","color:red")
> DropDownList1.Items.Add(z)
> next
>
> -- bruce (sqlwork.com)
>
>
> "Vincent" wrote:
>
>> Hi,
>>
>> i would like to have a forecolor for each listitem with some values only
>> of
>> the dropdownlist:
>>
>> If i=5 ot i=10 or i=15 then apply red forecolor to those listitems
>> otherwise
>> no color.
>>
>> For i = 1 To 20
>> z = New ListItem("item" & i, i)
>> DropDownList1.Items.Add(z)
>> ??
>> next
>>
>> Thanks
>> Vincent
>>
>>
>>



 
Reply With Quote
 
Vincent
Guest
Posts: n/a
 
      7th Mar 2008
The error is the missing ADD:
z.Attributes.Add("style", "color:red")



"Vincent" <vi,@sd.cv> schreef in bericht
news:(E-Mail Removed)...
> Hi, thanks but i get the error::
> "property access must assign to the property or use its value"
>
>
> "bruce barker" <(E-Mail Removed)> schreef in bericht
> news:E4C9398F-2A49-4703-8817-(E-Mail Removed)...
>> For i = 1 To 20
>> z = New ListItem("item" & i, i)
>> If i=5 ot i=10 or i=15 then z.Attributes("style","color:red")
>> DropDownList1.Items.Add(z)
>> next
>>
>> -- bruce (sqlwork.com)
>>
>>
>> "Vincent" wrote:
>>
>>> Hi,
>>>
>>> i would like to have a forecolor for each listitem with some values only
>>> of
>>> the dropdownlist:
>>>
>>> If i=5 ot i=10 or i=15 then apply red forecolor to those listitems
>>> otherwise
>>> no color.
>>>
>>> For i = 1 To 20
>>> z = New ListItem("item" & i, i)
>>> DropDownList1.Items.Add(z)
>>> ??
>>> next
>>>
>>> Thanks
>>> Vincent
>>>
>>>
>>>

>
>



 
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
DropDownList ListItem Rendering &nbsp; PJ Microsoft ASP .NET 1 26th Jan 2006 03:40 AM
Inserting a default ListItem in DropDownList Control =?Utf-8?B?QW1pIFNjaHJlaWJlcg==?= Microsoft ASP .NET 1 13th Jan 2006 11:49 PM
disabling a listitem in a dropdownlist Loui Mercieca Microsoft ASP .NET 0 26th Aug 2005 01:54 AM
DropDownList and ListItem Fabio Negri Cicotti [MCP] Microsoft C# .NET 10 8th Dec 2004 04:30 PM
additional Values in ListItem (DropDownList) Sebi Microsoft ASP .NET 6 18th Nov 2003 12:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:47 PM.