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

Find Records by value

1 Answer 58 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Muthu
Top achievements
Rank 1
Muthu asked on 05 May 2011, 01:16 PM
Hi,
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.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 May 2011, 04:30 PM
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.

Greetings,
Stefan
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.
Tags
DropDownList
Asked by
Muthu
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or