This question is locked. New answers and comments are not allowed.
How do you get the underlying item bound in a combobox ?
i set like this
i set like this
cbbTO.DataSource = GetMyObjList();
cbbTO.ValueMember = "Id";
and when i want to get the selected one
cbbTO. SelectedItem as MyObj;
returns null?
How can i get the selected databound Item?
thanks
7 Answers, 1 is accepted
0
Hello Louis ,
Initially, when a data source is assigned to RadComboBox.DataSource property, there is no selected item. Then you can use SelectedIndex or SelectedItem properties to select an item. If you want to use SelectedValue property you should set a priori ValueMember property to the corresponding data field. If there is no selected item, the SelectedItem would return null.
Please check your implementation meets the necessary conditions. If it seems to be ok, please try to reproduce the problem in a small sample application and send it to us so we can examine it and find where is the problem.
Kind regards,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Initially, when a data source is assigned to RadComboBox.DataSource property, there is no selected item. Then you can use SelectedIndex or SelectedItem properties to select an item. If you want to use SelectedValue property you should set a priori ValueMember property to the corresponding data field. If there is no selected item, the SelectedItem would return null.
Please check your implementation meets the necessary conditions. If it seems to be ok, please try to reproduce the problem in a small sample application and send it to us so we can examine it and find where is the problem.
Kind regards,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Paul Yerre
Top achievements
Rank 1
answered on 26 Oct 2007, 04:41 AM
I am having the same issue...i have tried to get the bound data item by using
carentity1 = ctype(radcombo.selecteditem,carentity)
this does not work.
carentity1 = ctype(radcombo.selecteditem,carentity)
this does not work.
0
Hello Paul Yerre,
Most likely this is because the cast of the value returned by SelectedItem property does not succeed. Regardless of the type of this property (for example, an object), it returns an instance of the RadComboBoxItem, which is currently selected. If no item is currently selected, this property returns a value of null.
Please, don't hesitate to write us if you need any additional assistance.
Regards,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Most likely this is because the cast of the value returned by SelectedItem property does not succeed. Regardless of the type of this property (for example, an object), it returns an instance of the RadComboBoxItem, which is currently selected. If no item is currently selected, this property returns a value of null.
Please, don't hesitate to write us if you need any additional assistance.
Regards,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Paul Yerre
Top achievements
Rank 1
answered on 29 Oct 2007, 11:24 PM
so is it possible to get the object?
0
Hello Paul Yerre,
Yes, it is possible to do that using the ItemDataBound event. You could use the DataBoundItem property of the arguments to obtain RadComboBox item and the DataItem property to obtain the corresponding data object.
Then, you could assign the value of the DataItem to the RadComboBoxItem.Tag property and use the reference later. A different way is to obtain the corresponding data object through the current position on the binding source. However, this is possible only if the combobox control is bound to an IBindingList source.
Thank you for writing. Contact us again if you have any other questions.
Sincerely yours,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Yes, it is possible to do that using the ItemDataBound event. You could use the DataBoundItem property of the arguments to obtain RadComboBox item and the DataItem property to obtain the corresponding data object.
Then, you could assign the value of the DataItem to the RadComboBoxItem.Tag property and use the reference later. A different way is to obtain the corresponding data object through the current position on the binding source. However, this is possible only if the combobox control is bound to an IBindingList source.
Thank you for writing. Contact us again if you have any other questions.
Sincerely yours,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Mel Grubb
Top achievements
Rank 2
answered on 23 Mar 2009, 02:42 PM
I have to chime in and say that in my opinion, if the ValueMember has not been set to anything, then by default the SelectedValue property should return the original bound object. Having to manually copy the object to the item's Tag event is far from the expected behavior. The base windows controls do this, so I would think that the Rad controls, being a supposed improvement, would have at least the same capabilities. Certainly if the code to take the bound object and copy a reference off into the tag property can be represented in 5-6 lines of code, then a similar 5-6 lines of code which provide the normally expected behavior should find their way into the next release.
C'mon, copying the value into the tag? Are you serious? Make the control work the way its expected to out of the box. At a minimum, the controls should do what the built-in WinForm controls do. All the themeing support in the world won't make developers more productive if core functionality requires a series of manual workarounds.
C'mon, copying the value into the tag? Are you serious? Make the control work the way its expected to out of the box. At a minimum, the controls should do what the built-in WinForm controls do. All the themeing support in the world won't make developers more productive if core functionality requires a series of manual workarounds.
0
Hello Mel Grubb,
Thank you for constructive feedback - we do appreciate it. We completely agree with you that, at the very minimum, we should support the same features as the standard toolbox controls. We do our best to address this shortcoming as soon as possible (Q1 SP2, or Q2 2009).
Please write back if you have more suggestions, questions or would like to point out other gaps that you have spotted in our controls.
Greetings,
Victor
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Thank you for constructive feedback - we do appreciate it. We completely agree with you that, at the very minimum, we should support the same features as the standard toolbox controls. We do our best to address this shortcoming as soon as possible (Q1 SP2, or Q2 2009).
Please write back if you have more suggestions, questions or would like to point out other gaps that you have spotted in our controls.
Greetings,
Victor
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.