Web Development Tips and Tricks

In this blog, I will be posting tips and tricks which will be useful for web development.

Thursday, February 17, 2005

Coloring the DropDownList

Today I came upon a request about coloring the Dropdownlist list items with different colors. I found that it could not be done as the has no attribute like backcolor.

I found from the web that we can do this by adding an attribute to it.
iterate through the listitems and then add the Style atrribute
For i = 0 To ddl.Items.Count - 1
ddl.Items(i).Attributes.Add("style", "color:#cccccc")
Next

1 Comments:

At 6:10 AM, Blogger Swarna said...

I found that I cannot change the font family using this style attribute. It is applicable only for htmlselect controls.

 

Post a Comment

<< Home