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

Problem with RadComboBox and SelectedValue

9 Answers 361 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.
Derek
Top achievements
Rank 1
Derek asked on 28 Jan 2009, 08:56 AM
Hi I have a RadComboBox wihich is populated by a datatable. This is fine. I map the id to an id in my main table using SelectedValue. I have a check in CurrentRowChanging event to see if there are pending changes and there always are, It's as if the combobox keeps setting the rowstate as modified, even though   the values haven't changed.  Any Ideas?

9 Answers, 1 is accepted

Sort by
0
Derek
Top achievements
Rank 1
answered on 28 Jan 2009, 10:25 AM
also, the combobox always stays on the first row even though I've set the SelectedValue
0
Nick
Telerik team
answered on 30 Jan 2009, 06:14 PM
Hi Derek,

Thank you for your question. I cannot completely understand it though. Can you send us same code of what you have tried? I am looking forward to helping you further on that.

Kind regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jon
Top achievements
Rank 1
answered on 09 Jun 2009, 12:24 PM
Hi,

I've got the same issue I think.

I setup the combo box with a dataset and it all works.  However in my code when I set ComboBox.SelectedValue = y where y is one of the IDs in the dataset nothing gets set - the entry in the list when it appears on screen is simply set to the first item in the list.

Do I have to set the selected value before the list gets bound to the dataset?

Seems very weird to have a property and then not bother using it.

Please could someone provide suggestions on selecting a value in a list programatically.

Regards,

Jon
 
0
Jon
Top achievements
Rank 1
answered on 09 Jun 2009, 03:11 PM
This seems somewhat mad.

I've worked out a work around to get the ID that should have been selected to be selected.  Luckily the SelectedText property does amazingly seem to work .

                    uxEditStatus.SuspendLayout()  
                    For Each item As Telerik.WinControls.UI.RadComboBoxItem In uxEditStatus.Items  
                        If item.Value.ToString() = IDTOMATCH Then uxEditStatus.SelectedText = item.Text  
                    Next 
                    uxEditStatus.ResumeLayout() 

I'd love to know if the SelectedValue property is a somewhat odd 'feature' or if it is a bug...

Regards,

Jon

0
Jon
Top achievements
Rank 1
answered on 09 Jun 2009, 03:24 PM
Or use the FindIndex sub below and pass it the combobox and ID to find.  Perhaps this functionality could be introduced into the combobox in a future release if the SelectedValue is by design?

Public Sub FindIndex(ByRef combobox As Telerik.WinControls.UI.RadComboBox, ByVal indexValue As String)  
    combobox.SuspendLayout()  
    Dim i As Integer = 0  
    For Each item As Telerik.WinControls.UI.RadComboBoxItem In combobox.Items  
        If item.Value.ToString() = indexValue Then combobox.SelectedIndex = i  
        i += 1  
    Next 
    combobox.ResumeLayout()  
End Sub 
0
Nick
Telerik team
answered on 10 Jun 2009, 02:59 PM
Hello Jon,

Thank you for contacting us. I cannot reproduce the bug you reported using the following test code:

private void Form2_Load(object sender, EventArgs e) 
 
            DataTable t = new DataTable(); 
            t.Columns.Add("A"typeof(string)); 
            t.Columns.Add("B"typeof(int)); 
            t.Rows.Add("text 1", 0); 
            t.Rows.Add("text 2", 1); 
            this.radComboBox1.DataSource = t; 
            this.radComboBox1.DisplayMember = "A"
            this.radComboBox1.ValueMember = "B"
             
 
        
private void radButton1_Click(object sender, EventArgs e) 
            this.radComboBox1.SelectedValue = 1; 

However, we are very eager to help you further. Please double check your code, and if everything seems ok, send us a sample application or code snippet that reproduces the issue. In this regard, do you use the latest release - Q1 2009 SP1?

All the best,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jon
Top achievements
Rank 1
answered on 11 Jun 2009, 11:18 AM
Hi Nick,

Thanks for the reply.

No I haven't installed SP1 yet, must have a try when I can't get a work around on any issues.

I'm on a tight deadline at the moment so can't check into the issue at the moment and would create a new ticket with the application but it's got some merge replicated data controlled by mac addresses etc so will need to do some editing.

When I've gotten past the deadline I'll come back to this as I'm sure that it's a bug somewhere (either my code or the Telerik code).

Best Regards,

Jon
0
Nick
Telerik team
answered on 11 Jun 2009, 11:55 AM
Hello Jon,

Please take your time. We will be glad to check your sample application after your deadline. 

All the best,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ankhaa
Top achievements
Rank 1
answered on 11 Dec 2013, 08:30 AM
Hi, John

I've a problem too. But i solved the problem. You have to check field type in your table. In my case i'm using MSSQL 2005, the table field type was numeric(18,0),  i changed it to Int type. The radDDL.selectedvalue=[number] has no problem.

Anhaa
Tricom
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Derek
Top achievements
Rank 1
Answers by
Derek
Top achievements
Rank 1
Nick
Telerik team
Jon
Top achievements
Rank 1
Ankhaa
Top achievements
Rank 1
Share this question
or