Load of Demand - Unable to Set SelectedValue

5 posts, 0 answers
  1. Jeff Reinhardt
    Jeff Reinhardt avatar
    55 posts
    Member since:
    Oct 2009

    Posted 21 Oct 2010 Link to this post

    I have two load on demand radcomboboxes that are working great, however, in the page load I try to set the seleceted value to session values:
    if (Session["FacilityID"] != null)
                {
                    FacilityID = Utils.ToInteger(Session["FacilityID"].ToString());
                    if (Utils.ToInteger(radcmbFacility.SelectedValue.ToString()) != FacilityID)
                    {
                        radcmbFacility.SelectedValue = FacilityID.ToString();
                    }
                }
    if I pause execution of the code, the line setting the value does run, and after it runs I can hover over the SelectedValue and it shows the correct value, however,  on the page the combobox still shows the empty message instead of the text for the selected value.





  2. Richard M
    Richard M avatar
    15 posts
    Member since:
    Feb 2010

    Posted 21 Oct 2010 Link to this post

    I have seen this same behavior.   I believe this is done on purpose.  If everytime the dropdown opened, or the items were requested, it would select your value.   So you'd never be able to change it.  It would keep defaulting back.   I think it has to work this way to work at all.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff Reinhardt
    Jeff Reinhardt avatar
    55 posts
    Member since:
    Oct 2009

    Posted 21 Oct 2010 Link to this post

    I understand and see what you are saying Richard, but there should be a way to set an initial value and then ignore it one future posts just like using IsPostback on a regular form page.  Here I could do the same thing so why not allow it to be set, then it is the coders responsibility to make sure they are not overriding a user, cause if I set a textbox and do not check postback, it will continue to replace a user's input too.
  5. Richard M
    Richard M avatar
    15 posts
    Member since:
    Feb 2010

    Posted 21 Oct 2010 Link to this post

    I have struggled with this on my project for a couple months now.   I think what you say there might have to do with the ajax command they use to load on demand, it happens before viewstate.   And since it's load on demand, it's always a postback.

    I'm with you, it'd be nice if there was a solution to this, I know I could use it to meet some customer demands, but I have had to work around it as a limitation of the control.

    Does this help?  It wasn't a solution for me.

    http://www.telerik.com/support/kb/aspnet-ajax/combobox/setting-an-initial-value-in-radcombobox-while-using-load-on-demand.aspx
  6. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 21 Oct 2010 Link to this post

    Hello Jeff,

    You should also set the Text property to the SelectedValue. The reason being, is because the RadComboBox has no items in it, setting a selected value will not set the text.

    I hope that helps.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017