Afternoon Nathan
Im not sure how frowned upon the practise of stylising individual options
within a select is but:
In the html code you could just add the style tag to the listitem
declaration (sure, its not there in intellisense but it should still show up
in ur broswer):
<asp:dropdownlist id="foo" runat="server">
<asp:listitem value="bar" style="background: #000000;">Bar it
up</asp:listitem>
</asp:dropdownlist>
or if you are using code to add items to the dropdownlist, then you could
add attributes to each listitem:
ListItem li = new ListItem();
li.Value = "bar";
li.Text = "Bar it up";
li.Attributes.Add("style", "background: #000000;");
Foo.Items.Add(li);
Also be aware that some css styles will not work when applied to
dropdownlists and possibly their child listitems.
Graham
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
I want to change the background color, font attributes, etc. of the choices
in my DropDownLists. When writing them using HTML SELECT and OPTION tags, I
can do something like the following:
<option
style="font-weight:bold;color:green;background-color:purple;">Displayed
Text</option>
but the ListItem Control does not have a Style property, which prevents me
from doing anything other than specifying the Text, Value, and Selected
properties. Is there any way to format the ListItem Control, such as some
kind of workaround (I know I could write my own Control that inherits
ListItem, but I have very little experience doing this, so I might do it
in the future, but for the moment I am looking for a workaround)?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/