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

RadComboBox SelectedItem not working

6 Answers 610 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Muhammad Irfan
Top achievements
Rank 1
Muhammad Irfan asked on 31 Jan 2011, 01:18 PM
Hi Telerik Support,

I am having a problem with RadComboBox. I am not able to select the first item of RadComboBox programmatically. I have instantiated  a RadComboBox with 2 columns. I am giving user the ability to filter combo box based upon items present either in column 1 or 2. The search criteria may not necessarily appear in the beginning of the dropdown items, it may appear anywhere in the text. For example I have a dropdown with 2 columns with first column having "Project Engineer" and second "VAC-1001". My user types "1001" as search criteria and system brings one record, but that record (RadComboBoxItem) is not being selected.

I have set MarkFirstMatch property to "true". I tried setting SelectedItem to its text but getting below error:

"Property 'SelectedItem' is 'ReadOnly'."

I also tried using SelectedIndex, but that is also not working. Please help me select the first item. I am using 2010.2.713.35 verion of Telerik.Web.UI and Telerik.Web.Design.

If RadComboBox.Items.Count > 0 Then
 RadComboVacancyList.SelectedIndex = 0
End
If

Many thanks.

6 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 02 Feb 2011, 03:10 PM
Hello Muhammad Irfan,

I am afraid that we will need more details about your implementation.
Could you please send us a simplified runnable page where we will be able to observe the issue?
Do you use Load On Demand?
I was not able to understand what you mean by “… but that record (RadComboBoxItem) is not being selected.”?  Do you want the item to be selected or you expect it to be highlighted?

All the best,
Kalina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Muhammad Irfan
Top achievements
Rank 1
answered on 14 Jun 2011, 09:36 AM
I sorted that out myself. 

Thanks
0
Nils C.
Top achievements
Rank 1
answered on 16 Dec 2011, 10:41 AM
Hi Muhammad,
would you mind telling us how? We've got the same issue.

Best
0
Karlo
Top achievements
Rank 1
answered on 16 Jan 2012, 02:43 AM
Had the same experience. RadComboBox SelectedItem Property is Read-Only (v. 2011 q3 SP1). My solution was

...
radComboBox.SelectedIndex = radComboBox.FindItemIndexByText(dataItemValue);
...
0
danparker276
Top achievements
Rank 2
answered on 28 Feb 2013, 06:34 AM
So that above works I guess.  Is this the best way to do it?  I've been doing WPF/Silverlight for the past 3 years, what pain that this doesn't work easy
0
Boyan Dimitrov
Telerik team
answered on 04 Mar 2013, 11:43 AM
Hello,

Indeed the provided solution works fine and selects the specific item that has  "textValue" value as Text property.
//code behind
RadComboBox1.SelectedIndex = RadComboBox1.FindItemIndexByText("textValue");

Alternative way of achieving that functionality would be to iterate through all items and set that specific item Selected property to true.
//code behind
for (int i = 0; i < RadComboBox1.Items.Count; i++)
       {
           if (i == 2)
           {
               RadComboBox1.Items[i].Selected = true;
           }
       }


All the best,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Muhammad Irfan
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Muhammad Irfan
Top achievements
Rank 1
Nils C.
Top achievements
Rank 1
Karlo
Top achievements
Rank 1
danparker276
Top achievements
Rank 2
Boyan Dimitrov
Telerik team
Share this question
or