Find Records by value

2 posts, 0 answers
  1. Muthu
    Muthu avatar
    10 posts
    Member since:
    Oct 2010

    Posted 05 May 2011 Link to this post

    Im using telerik RadComboBox. It is populated it using a datatable. While populating i set both the text and value fields. Later I'm trying to find whether a record is available using the value(not text). pls let me know how.
    Code for populating:
    cmbState.DataSource = stateTable;
    cmbState.DisplayMember = "state_name";
    cmbState.ValueMember = "state_code";

    code for retrieving:
    if (cmbState.FindItem(dr["OWNER_STATE_CODE"].ToString().Trim() ) != null)
        index = cmbState.FindItem(dr["OWNER_STATE_CODE"].ToString().Trim() ).Index;
        cmbState.SelectedIndex = index;

    here im checking based on the displaymember property. But i want to check based on the value member property.
  2. Stefan
    Stefan avatar
    2911 posts

    Posted 09 May 2011 Link to this post

    Hello Muthu,

    Thank you for writing.

    Before getting to your question, I would like to let you know that RadComboBox control is obsolete since Q2 2010. Once we release Q2 2011, this control will no longer be supported. This is why, it is highly recommendable to upgrade to its ancestor - RadDropDownList.

    As to your question at hand, the Find methods of RadComboBox are always searching by the display text of the items. So you can achieve the desired behavior by either setting both the display and the value members of the control to the value or you can simply iterate over the combo items in a for loop and search the value member for the desired value.

    I hope the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.

    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top