RadComboBox - LoadOnDemand and Setting Initital Value/Text

12 posts, 0 answers
  1. Angelo Babudro
    Angelo Babudro avatar
    12 posts
    Member since:
    Dec 2006

    Posted 04 Feb 2008 Link to this post

    I have several RadCombo boxes (latest install of Prometheus) on a screen that I wish to use for editing and adding new orders. I am using LoadOnDemand (via RadComboBox1_ItemsRequested) to populate the combo boxes with data from a SQL server database.  However when editing an existing order how do I display the existing values in the database? The LoadOnDemand doesn't kick off until you actually access the combo box... I have seen several of the online demos that Telerik staff say to reference but none of them work...They say that LoadOnDemand dos not have any notion of binding or selecteditem/selectedvalue. They say instead to use the .Value and .Text property...however there is no such property as .value

    To further complicate things several combo boxes are dependent on one another...i.e. select something from one combo box and the items in the second are "filtered"

    Any help would be appreciated.
  2. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 05 Feb 2008 Link to this post

    Hi Ashley Murray,

    With RadComboBox Prometheus you should be able to use the SelectedValue property to obtain the value of the selected item even in a callback mode. What does the SelectedValue property return in your case?

    To set an initial value/text you can use the set_value and set_text methods of the combobox objects. You can hook on the client-side onload event of the page (<body onload="...">) and call the methods in the event handler.

    Kind regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Angelo Babudro
    Angelo Babudro avatar
    12 posts
    Member since:
    Dec 2006

    Posted 05 Feb 2008 Link to this post

    Nick:

    The problem isn't returning the selected value the problem is setting it... Becuase I am using LoadOnDemand=True, when the page first loads the combo box is empty until I click the drop down and then the items are retrieved. All is well and good at that point...I can select a value and move on. However this same form is not only used to add new orders but is also used to view existing orders. So now the page is hit with an orderid in the querystring. I grab that, retrieve the order and want to display it. So now how do I set the value and text in the combo box so the user can see it and then change it if required? For example a combo box might be for displaying countries...

    Country ID        Country Text
    1                       USA
    2                        Canada
    3                        Mexico

    You mention using javascript...can you please provide a small sample app?

    Thank you.
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 06 Feb 2008 Link to this post

    Hi Ashley Murray,

    As you want to use QueryString you can do something like this:

    protected void Page_Load(object sender, EventArgs e) 
        if (!IsPostBack) 
        { 
            if (Request.QueryString["orderID"] != null
            { 
                RadComboBox1.Text = Request.QueryString["orderID"].ToString(); 
            } 
        } 


    I hope this helps.

    Sincerely yours,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Angelo Babudro
    Angelo Babudro avatar
    12 posts
    Member since:
    Dec 2006

    Posted 06 Feb 2008 Link to this post

    Yes setting the text is certainly no problem. But its the associated datavalue (i.e. Key id that is the problem). According to some of your posts there is supposed to be a RadComboBox1.Value property but no such property exists.

    I need to be able to set both the Key id value and the text value because as with a fully normalized database it's the Key value that is actually stored with the record and the text comes from a lookup table.

    Thank you.
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 06 Feb 2008 Link to this post

    Hi Ashley Murray,

    You can also set the SelectedValue property of the combobox to the appropriate value (ID)

    // set the SelectedValue to the appropriate ID  
    RadComboBox1.SelectedValue = Request.QueryString["orderID"].ToString(); 

    To summarize: when you get the orderID you can set the Text and the SelectedValue of the Combobox.


    Regards,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Kyle
    Kyle avatar
    27 posts
    Member since:
    Sep 2008

    Posted 29 Oct 2008 Link to this post

    I am experiencing pretty much the same problem in the latest version of the RadCombo.  I have a RadCombo with loadondemand enabled.  On page load the selectedvalue is set to a particular value.  In this case it is an account code.  However, nothing displays in the radCombo because none of the accounts have been loaded.  If I click the drop arrow, the control loads.  If I then click away from the control to make the control loose focus, the selected value is now showing the correct text.  I realize that I can set the text manually on the page load, however we are trying to reduce sql calls whenever possible.  Being supplied with just the account code, I do not want to have to go look up the account name via sql just to set the text on the control.  I realize this is more of an inherent design flaw of load on demand.  Is there a better work around then just doing a manual lookup?

    Thanks,
    Kyle
  9. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 03 Nov 2008 Link to this post

    Hi Kyle,

    With load-on-demand enabled, the items of the combobox are not added initially. You need to do something (click the dropdown or call the requestItems method) to add the items to the control. The combobox has no idea what is the text of the item if it knows only the SelectedValue and the items are not loaded as in your case. So, you need to do a query to get the text of the selected item and set it as a text of the combobox.

    Kyle, can you explain in more detail what is your scenario?

    Greetings,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Craig Corbin
    Craig Corbin avatar
    6 posts
    Member since:
    Sep 2008

    Posted 05 Oct 2009 Link to this post

    Even in the latest version (at the time of writing) of the RadCombo, the tooltip for the RadCombo.SelectedValue only describes the getter and not the setter.  Regardless, the setter is there and it does work.

    I used the following to get an initial value to display...

    RadCombo.SelectedValue = EmployeeId;

    RadCombo.Text = EmployeeName;

    Craig

  11. EJ
    EJ avatar
    39 posts
    Member since:
    Jun 2012

    Posted 21 Jul 2010 Link to this post

    is there a way to do this using declarative databinding (e.g. Bind() in markup) rather than manage it manually like this?
  12. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 22 Jul 2010 Link to this post


    If you use RadComboBox with load on demand  - for example in EditItemTemplate of FormView - you cannot declaratively set the SelectedValue (SelectedValue ='<%#Bind("something") %>').
    The same is for GridView or RadGrid “Edit” templates.

    This happens because when such combo is loaded on the page - there are no items in it. The control requests its items when you click/write in the input,  or click on the arrow (in case there are no items loaded).
    This is the way load on demand works.

    You can hook the DataBound event, create manually and preselect one item or simply set the Text and SelectedValue in the combo.
  13. Kanna
    Kanna avatar
    5 posts
    Member since:
    Aug 2010

    Posted 04 Apr 2012 Link to this post

    Hi, Me too had the same issue with RadCombo when using LoadOnDemand.

    The solution Mr. Cat Cheshire suggested is working fine.
    Just assign text property and followed by SelectedValue property of radCombo in that case.

    Thanks,
    Santhosh
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017