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

Refresh items without rebinding

3 Answers 89 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jorge
Top achievements
Rank 1
Jorge asked on 08 Jul 2010, 11:17 AM
I have two nested RadComboBox controls. Both "SelectedValue" properties are bound to a LinqDataSource, and they both get items from different ObjectDataSources.

When I select an item in RadComboBox1 I want to update RadComboBox2's items but I'm getting the following error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." as RadComboBox2 is also rebinding the SelectedValue property. To solve this, I unbind RadComboBox2.SelectedValue and set the field's value later, but I'm looking for a nicer option.

Is there anyway to refresh RadComboBox2 items withouth the whole rebind, so as to prevent the exception from raising?
Thanks a lot!

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 14 Jul 2010, 06:06 AM
Hello Jorge,

I am not sure that I understand the issue that you describe.
Maybe your RadComboBox controls are nested in “Edit” Template of another parent control(RadGrid, GridView or FormView) and you use Load-On-Demand to populate them with data?

Please note that by design when a RadComboBox with enabled Load-On-Demand(or Automatic-Load-On-Demand) feature is loaded - it is empty and it has no items.
Load-On-Demand/Automatic-Load-On-Demand fires and populates the control with data when the user types in the input area or clicks on the drop-down toggle image when there are no items in the RadComboBox. That is why you receive an error when trying to set the SelectedValue='<%# Bind("some value") %> ‘.


Best wishes,
Kalina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jorge
Top achievements
Rank 1
answered on 14 Jul 2010, 05:42 PM
This is the structure:
FormView / Edit template
RadComboBox: State
RadComboBox: Cities
Both linked to a dataset using SelectedValue property.

When I change "State", I need to rebind "Cities" with the related cities. This Cities.Bind() throws "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control".
If, however, I don't bind the SelectedValue then everything goes ok.

Thanks!
0
Kalina
Telerik team
answered on 19 Jul 2010, 05:35 PM
Hello Jorge,

As I already explained at my previous post:
"Load-On-Demand/Automatic-Load-On-Demand fires and populates the control with data when the user types in the input area or clicks on the drop-down toggle image when there are no items in the RadComboBox.
That is why you receive an error when trying to set the SelectedValue='<%# Bind("some value") %> ‘.
"

I prepared a small sample project to illustrate the approach that you can follow in order to implement related RadComboBoxes in FormView control - please find it attached.

All the best,
Kalina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Jorge
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Jorge
Top achievements
Rank 1
Share this question
or