SelectedValue is not updated on server side

2 posts, 0 answers
  1. Andy
    Andy avatar
    54 posts
    Member since:
    Jun 2009

    Posted 07 Sep 2010 Link to this post


    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!
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 07 Sep 2010 Link to this post

    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.
Back to Top