It really depends on how you're populating the DDL. You need to explain more. But here's how you can set the color for one item: DropDownList1.Items[0].Attributes.Add("style", "background-color: red");
Oh sorry. I just noticed your question is in a starter kit forum. I don't know anything about the classifieds starter kit. I was just giving a general webforms asnwer where you can iterate through a DDLs Items collection and set the style as I described
to change the color.
MetalMutant
Member
8 Points
6 Posts
Different background colors in the dropdownlist
Feb 05, 2012 09:32 AM|LINK
Hi there!
Is it possible to have different background colors in the dropdownlist? One color for main categories and another color for subcategories..
I would be very happy if someone could tell me how its done, and were to put the code :)
I also want to change the listing order of the categories, I dont want to have from A-Z, I want to change it manually if its possible...
Thanx in advance!
/Peter
MetalAsp.Net
All-Star
112201 Points
18262 Posts
Moderator
Re: Different background colors in the dropdownlist
Feb 05, 2012 09:59 AM|LINK
It really depends on how you're populating the DDL. You need to explain more. But here's how you can set the color for one item: DropDownList1.Items[0].Attributes.Add("style", "background-color: red");
MetalMutant
Member
8 Points
6 Posts
Re: Different background colors in the dropdownlist
Feb 05, 2012 10:29 AM|LINK
Hey thanx for your answer!
But where should I put DropDownList1.Items[0].Attributes.Add("style", "background-color: red"); ? In CategoryDropDown.ascx?
If I put it this way, I want the background of all the MAIN categories in the dropdownlist to be light blue... Thats all I want to do. :)
How do I achieve that? I use Asp.Net VB by the way...
Thanx
/Peter
MetalAsp.Net
All-Star
112201 Points
18262 Posts
Moderator
Re: Different background colors in the dropdownlist
Feb 05, 2012 02:54 PM|LINK
Oh sorry. I just noticed your question is in a starter kit forum. I don't know anything about the classifieds starter kit. I was just giving a general webforms asnwer where you can iterate through a DDLs Items collection and set the style as I described to change the color.