Dropdownlist in ASP.net C# -
i have 2 dropdownlist's.dropdownlist2(not bound datasource) , dropdownlist3(bound datasource)
on change on input in 1 dropdownlist content in other dropdownlist should change. had used logic as.
autopostback enabled both controls.
protected void dropdownlist2_selectedindexchanged(object sender, eventargs e) { if (dropdownlist2.selecteditem.text == "stamp") { dropdownlist3.items.remove(dropdownlist3.items.findbytext("sta")); dropdownlist3.items.remove(dropdownlist3.items.findbytext("stm")); } <asp:dropdownlist id="dropdownlist3" runat="server" datasourceid="sqldatasource1" datatextfield="skey" datavaluefield="casecode" appenddatabounditems="true" autopostback="true"> <asp:listitem selected="true" value="s">select</asp:listitem> </asp:dropdownlist>
now problem when select dropdownlist2.selecteditem.text == "reg"
sta , stm not present. want sta , stm values in dropdownlist on selection of 'reg'.
when first load page , select 'reg' values in dropdownlist3(including 'sta' , 'stm') present , when select 'stamp' values 'sta' , 'stm' lost(as shown in code). again when select 'reg' values not there, want values present again.
what have do?? have bind again database?
is there other logic used in different way ?if can me
if know values of dropdown items, can add them in else clause, if don't know value/text combination you'll have rebind.
Comments
Post a Comment