Returning the ID of a selected Item

2 posts, 0 answers
  1. Eddie
    Eddie avatar
    2 posts
    Member since:
    Oct 2012

    Posted 06 Dec 2007 Link to this post

    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

  2. Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 07 Dec 2007 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top