0

I have a dropdownlist to which I bind data in c#. After binding, I assigned class to individual items based upon a condition.

foreach (ListItem li in ddlTrend.Items)
{
   if (li.Value == "S")
   {
        li.Attributes["class"] = "optionGroup";
   }
   else
   {
        li.Attributes["class"] = "optionChild";
   }
}

The code of CSS is

.optionGroup {
     font-weight: bold !important;
}

.optionChild {
     padding-left: 15px !important;
}

Now this works perfectly in IE (v 11) and Firefox (v 30)

enter image description here

but does not works in Chrome (v 36)

enter image description here

Any help would be appreciated

Hitesh
  • 3,449
  • 8
  • 39
  • 57
  • 1
    I don't think you can style drop down lists http://stackoverflow.com/questions/1895476/how-to-style-a-select-dropdown-with-css-only-without-javascript – Pete Jul 29 '14 at 14:29
  • Thanks a lot Pete for that link, will see if I can do any workarounds for it – Hitesh Jul 30 '14 at 07:29
  • You could also try using [option groups](http://stackoverflow.com/questions/16167862/how-can-i-add-option-groups-in-asp-net-drop-down-list) – Pete Jul 30 '14 at 07:40

0 Answers0