c# - how to change change the colour of dropdown in Asp.net? -




i have dropdown cbovendor want data in dropdown in red coming else part in below code.but problem binding data after if-else.

.aspx

<asp:dropdownlist id="cbovendor" runat="server" appenddatabounditems="true" autopostback="true"> <asp:listitem value="0">- select vendor -</asp:listitem> </asp:dropdownlist> 

c# code

if (checkbox1.checked == true) {     cbovendor.datasource = dal.certificationda.getfullaccreditedvendors(vendid);     cbovendor.datatextfield = "suppliername";     cbovendor.datavaluefield = "supplierid"; } else {     cbovendor.datasource = supplier.getsuppliersforsite(userwrapper.getcurrentuser.getvalidlocations.wsm_ref_buildings.findbybuildingid(cbobuilding.selectedvalue).siteid);     cbovendor.datatextfield = "suppliername";     cbovendor.datavaluefield = "supplierid"; } cbovendor.databind(); 

after binding data can loop through list items , can set style or class on items this

  if(checkbox.checked!=true){        foreach(listitem item in cbovendor.items) {                     item.attributes.add("style", "background-color:red;");        }      } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -