asp.net - Initial selection for a DropDownList overriding user selection -
i'm trying set initial selection dropdownlist calling: drop.selectedindex = 5 in page_load. works, if change selection manually , want save form, i'm still getting initial selection instead of new selection when calling drop.selectedvalue. what's wrong?
you have forgotten check if(!ispostback)
. otherwise select 6th item again on postbacks before selectedindexchanged
event triggered (or button-click event):
protected void page_load(object sender, eventargs e) { if(!ispostback) // on initial load , not on postbacks dropdwonlist1.selectedindex = 5; }
Comments
Post a Comment