I have a WebDropDown "DDthisWeek" representing the week number of a year in my page and filled not from a datasource but only by Items 1 to 52.While loading the page in the preload event I set one item to be the selected item e.g. that item that the actual week represents. That works so far.But now if the user selects an other item in that DropDown the DDthisWeek_SelectionChanged is fired. Now in the code of this event handler I want to find out, which new value is selected and so I tried this:
Dim var = DDthisWeek.selectedValue
val idx = me.DDthisWeek.ActiveItemIndex
2. now using this to set the selection:
Me.DDthisWeek.Items(idx).Selected = True
3.no this has the expected value:
var = DDthisWeek.selectedValue
But this works only the first time! If I now select another Item, I get the correct ActiveItemIndex but line 3 gives me still the old value.How can I get the correct value after the user has selected an item.
my DropDowns code ist
<ig:WebDropDown ID="DDthisWeek" runat="server" Width="50px" AutoPostBack="False" AutoPostBackFlags-SelectionChanged="On"> <AutoPostBackFlags SelectionChanged="On" /> <Items> <ig:DropDownItem Key="01" Selected="False" Text="01" Value="01"> </ig:DropDownItem> <ig:DropDownItem Key="02" Selected="False" Text="02" Value="02"> </ig:DropDownItem> <ig:DropDownItem Key="03" Selected="False" Text="03" Value="03"> </ig:DropDownItem> ..... <ig:DropDownItem Key="50" Selected="False" Text="50" Value="50"> </ig:DropDownItem> <ig:DropDownItem Key="51" Selected="False" Text="51" Value="51"> </ig:DropDownItem> <ig:DropDownItem Key="52" Selected="False" Text="52" Value="52"> </ig:DropDownItem> </Items> </ig:WebDropDown>
Hello,
I have recreated a sample project following the pattern you describe here, but the behavior i'm experiencing is as expected. That is, upon changing the selection in the WebDropDown, the SelectedValue is adjusted to the current value of the WebDrowDown list. I've tested by changing the WebDrowDown value several times to verify correct behavior. If you send me your sample I will take a look to see what's happening.
Sincerely,TroyDeveloper Support Engineer
Ok. I created a sample showing this effect. Here I have one dropdown and this dropdown is set in the page_preload event to a value which is representing the actual week number of a year. Now try to select an other week number. The DDthisWeek_SelectionChanged event is fired and there the new selected value is expected. As you can see there in the first line (there is a breakpoint) the old value was recieved.