How do I put a CSS class onto a ListItem of a drop-down list?
I've tried the following, but no class attribute is output in the HTML:
ddlChainSupplierAndNonChainDealer.DataSource =
GetChainSupplierAndNonChainDealerDataSource();
ddlChainSupplierAndNonChainDealer.DataValueField = "CompanyId";
ddlChainSupplierAndNonChainDealer.DataTextField = "Name";
ddlChainSupplierAndNonChainDealer.DataBind();
if (selectedIndex > 0)
ddlChainSupplierAndNonChainDealer.SelectedIndex = selectedIndex;
foreach (ListItem li in ddlChainSupplierAndNonChainDealer.Items)
li.Attributes["class"] = "forhandlerdrop_on";
The code is called from CreateChildControls().
Regards,
Casper Hornstrup
|