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

RadComboBox in RadGrid and filtering lists

2 Answers 130 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Amanda
Top achievements
Rank 1
Amanda asked on 21 Apr 2008, 09:11 PM
Hello,

I have a RadGrid with a custom edit form containing several RadComboBoxes.  One of these comboboxes filters the list contained in the other two - when the user selects from a list of countries, a combobox containing a list of states/provinces is filtered to contain only valid items for that country, and the same with a list of timezones.  My problem is that I cannot figure out how to get the two filtered lists to know the value of the parent combobox so that they can show the proper sub-set of values.  When a user is creating a new location, the two child comboboxes should be empty until the user selects a country, but on edit the two child comboboxes should display with all the filtered values and their previously entered value already selected.

I had this working nicely with server-side data binding, but ran into issues with setting the previously entered values.  So then I decided using declarative data binding would work better since it allows you to bind the data field in the .aspx file.  Now I can't figure out how to filter my child data sources.  The parent combobox is loading, but I don't know how to specify the parameter that should be passed to my select method in the two child datasources. 

Thank you.

2 Answers, 1 is accepted

Sort by
0
Amanda
Top achievements
Rank 1
answered on 23 Apr 2008, 06:43 PM
Well, I am further along than I was, but still having problems.  When the "Add" button is clicked, I have my form loading only the parent RadComboBox, and leaving the two child RadComboBoxes to load once the user selects a value in the parent.  All OK there.  On "Edit", I am using the ItemCreated to get the current row's values and assign the select parameter for the two data sources for the two child fields based on the parent field's values, and binding those two fields to their lists when the form is displayed.  Again, all is well there, except that when I try to save the values in the form, the two child fields are not bound to the datasource containing the list of items in the grid, and it fails.  

Because I am assigning the .DataSource property at runtime to the two child fields, I cannot use the SelectedValue='<%# Bind("fieldname") %>' syntax; that gives an error.  How can I bind these fields to the main datasource at runtime?
0
Simon
Telerik team
answered on 24 Apr 2008, 04:48 PM
Hi Amanda,

Why don't you set the SelectedValue right after you bind the ComboBox to its data source?

You can refer to the current GridItem's DataItem and set the SelectedValue to the corresponding field's value.

Greetings,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Amanda
Top achievements
Rank 1
Answers by
Amanda
Top achievements
Rank 1
Simon
Telerik team
Share this question
or