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

V

Vincent

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
 
B

bruce barker

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)
 
V

Vincent

Hi, thanks but i get the error::
"property access must assign to the property or use its value"
 
Joined
Jul 24, 2008
Messages
1
Reaction score
0
can you also change the color after adding the items

hi,

i am using databound dropdown. can i still change the color of some listitems in the dropdown. i tried with following code but it does not do anything and no error too.

thanks,
joy

Code:
for i=0 to DropDown.Items.count-1
 if Right(DropDown.items(i).value,1)="1" then
  DropDown.items(i).Attributes.Add("style","color:red")
 end if
Next
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top