Is it possible to open the insert form and select a resource from code behind?

7 posts, 0 answers
  1. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 17 Nov 2013 Link to this post

    I have a scheduler with two resources in the insert and edit forms. The first resource is the Employee, and the second is the customer. I am passing the customer id into the page and want to open the insert form and select the customer from the resource, based upon the customer id. How do I do this?
  2. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 18 Nov 2013 Link to this post

    Hi,

     
    You can refer to this help topic where in the Change the selected index of a resource combobox so always one option is preselected section is explained how to achieve similar behavior.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 18 Nov 2013 Link to this post

    Thanks for pointing me in the right direction. I tried this, but it is not working as I expected. Trying to set the selectedindex by the value doesn't work. The FindItemIndexByValue is returning -1, indicating not found. I validated the value being passed in for iCustomerID as being a valid value in the database. I changed it to FindItemIndexByText, passing in the customer name and it finds the item in the combobox no problem. So, I checked the value of the SelectedValue statement and instead of returning "692",  it is returning "/wECtAU=".

    customerResource.SelectedIndex = customerResource.FindItemIndexByValue(iCustomerID)

    IT looks like the value being returned is either encrypted or just plain garbage. Is this a bug in the combobox?

    How can I get it to find the item in the combo by the value?
  5. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 21 Nov 2013 Link to this post

    Hello Steve,

    By default values of the items is not bound to the resources RadComboBoxes and that is which we recommend using index or text to set the values. If you by some reasons need the values of the items we recommend using custom advanced form where you will be able to customize the control as you like.

    Hope this information will be helpful.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 25 Nov 2013 Link to this post

    I just looked at the project you referenced. There is no easier way? That project is massive. I have it loading the customers and employees fine, all I want to do is select one of the customers from the dropdown list upon load. To do this, I have to totally rewrite my whole project? I can't believe that's the only solution.
  7. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 25 Nov 2013 Link to this post

    I found a solution that will work for me, but it's a workaround for what I consider a bug in the RADComboBox control.
    I'm just passing in the customer name and executing the following logic to select the resource in the code-behind.

    customerResource.SelectedIndex = customerResource.FindItemIndexByText(CustomerName)
  8. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 27 Nov 2013 Link to this post

    Hello Steve,

    Thank you for sharing the code that worked at your side. Please excuse us for this limitation of the Resource RadComboBox -we will consider a possible improvement for the future versions of the control.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017