asp.net - Update dropdown after Items.Clear() -
i populate dropdown several items. when user chooses 1 of these items, second dropdown gets populated.
when user clicks on "x" button on first dropdown, 2 dropdown must cleared. first dropdown gets cleared automatically, , clear second dropdown using "dropdown.items.clear()".
it happens when load again data first dropdown, second dropdown not update.
this code:
protected void dropdowndiagstati_selectedindexchanged(object sender, eventargs e) { int selectedindex = this.dropdowndiagstati.selectedindex; populateddlstates(selectedindex); } private void populateddlstates(int selectedindex) { // ottengo diagrammi di stato in sessione arraylist diagrammistato = session["statediagrams"] arraylist; if(selectedindex > 0) { // ottengo il diagramma di stato selezionato docspawr.diagrammastato currdiagstato = (docspawr.diagrammastato)diagrammistato[selectedindex - 1]; // ottengo gli stati del diagramma di stato selezionato stato[] stati = currdiagstato.stati; for(int = 0; < stati.length; i++) { listitem item = new listitem(); item.value = convert.tostring(stati[i].system_id); item.text = stati[i].descrizione; this.dropdownstati.items.add(item); this.uppanelstatiddl.update(); } } else { this.dropdownstati.items.clear(); this.uppanelstatiddl.update(); } }
i see old value in second dropdown , cannot select it.
you need remove update pane or can set data source drop-down.
ddl1.datasource = datasource; ddl1.datatextfield = "name"; ddl1.datavaluefield = "id"; ddl1.databind();
Comments
Post a Comment