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

Returning the ID of a selected Item

1 Answer 93 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eddie
Top achievements
Rank 1
Eddie asked on 06 Dec 2007, 06:53 PM
Hi,

If I bind to a datatable, how can I get the ID of the selected item in the combo box. I have added the following code

Dim pobjTable As New Data.DataTable

pobjTable.Columns.Add("ID")

pobjTable.Columns.Add("Name")

pobjTable.Rows.Add(1001, "User A")

pobjTable.Rows.Add(1002, "User C")

pobjTable.Rows.Add(1003, "User B")

RadComboBox1.DataSource = pobjTable

RadComboBox1.DisplayMember = "Name"

So if User C is selected, I would like to get 1002 back as the ID.

Note: This is possible in the VB.Net Combo Box if you create a class to store the ID and the Text Value. You can add an object to the List and return the Object once selected.


Best Regards
Eddie

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 07 Dec 2007, 06:09 PM
Hi Eddie,

Yes, this is possible with our RadComboBox. You just have to set the ValueMember property to "ID". Then you can access the corresponding value for the currently selected item through the SelectedValue property.

If you have any additional questions, please do not hesitate to write us again.

 
Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Eddie
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or