This is a migrated thread and some comments may be shown as answers.

SelectedValue is not updated on server side

1 Answer 75 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 07 Sep 2010, 04:58 PM
Hello!

I have two "linked" comboboxes - Area (ddlArea) and Region (ddlRegion). When Area selection is changed, Region items need to be updated accordingly. Both comboboxes have "EnableAutomaticLoadOnDemand" set to true. I have a java-script handler assigned to OnClientSelectedIndexChanged of ddlArea combobox to avoid post back, because this is all done is a "colorbox" modal window, which needs to be reopened after each post-back.
function requestData(sender, eventArgs) {
            var ddlRegion = $find("<%=ddlRegion.ClientID %>");
            ddlRegion.requestItems(sender.get_value(), false);
        }

On the server side, in ItemsRequested handler I'm able to determine which value has been selected by processing "Text" property. of event arguments. However, with automatic LoadOnDemand feature enabled, binding needs to occur also on every post back, inside Page_Load method. But when I set a breakpoint inside Page_Load, I see that ddlArea.SelectedValue has it's old value and not the one that was just selected. ddlArea.SelectedValue becomes updated only after post-back from a button for example.

Could you please advise what's the best solution for my problem would be?
Thank you!

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 07 Sep 2010, 06:39 PM
Hello Andy,

AutomaticLoadOnDemand and LoadOnDemand in general uses callbacks, not postbacks. So that is the reason it only changes that value when a Postback is made by another control. Also, if you don't explicitly select the item from the ComboBox, meaning they type the entire selection and click enter, the SelectedValue property isn't set, so that is another reason it's not set.

I don't know how to overcome this issue, other than retrieving the value from whatever datasource you use and getting the value you need.

I hope that helps.
Tags
ComboBox
Asked by
Andy
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or