c# - how to change change the colour of dropdown in Asp.net? -
i have dropdown cbovendor want data in dropdown in red coming
elsepart in belowcode.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
Post a Comment