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

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

6 Answers 63 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 18 Nov 2013, 12:49 AM
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?

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 18 Nov 2013, 09:48 AM
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.
0
Steve
Top achievements
Rank 1
answered on 18 Nov 2013, 01:21 PM
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?
0
Plamen
Telerik team
answered on 21 Nov 2013, 12:50 PM
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.
0
Steve
Top achievements
Rank 1
answered on 25 Nov 2013, 05:41 PM
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.
0
Steve
Top achievements
Rank 1
answered on 25 Nov 2013, 10:44 PM
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)
0
Plamen
Telerik team
answered on 27 Nov 2013, 09:45 AM
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.
Tags
Scheduler
Asked by
Steve
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Steve
Top achievements
Rank 1
Share this question
or