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

Getting combobox value

2 Answers 160 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.
Web
Top achievements
Rank 1
Web asked on 15 Dec 2006, 01:51 PM
I am populating the text and values of a rad combobox from a hashtable using the following code:

   while (Enumerator.MoveNext())
            {
                cboOutputFormat.Items.Add(new RadComboBoxItem(Enumerator.Value.ToString(),(int)Enumerator.Key));
}

but when I try to retrieve the value of the selected item using:

int val = (int)((RadComboBoxItem)cboOutputFormat.SelectedItem).Value;

it comes up null... what am I doing wrong?

2 Answers, 1 is accepted

Sort by
0
Web
Top achievements
Rank 1
answered on 15 Dec 2006, 02:10 PM
figured it out.

Assigning the value through the constructor doesn't seem to work properly. If you create a new RadComboBoxItem and assign the value property, it works.

Thanks
0
aban
Top achievements
Rank 1
answered on 16 Apr 2007, 03:02 PM
Do you mean create one new RadComboBoxItem object, and don't use convert value (RadComboBoxItem)?

I will try this, Thanks.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Web
Top achievements
Rank 1
Answers by
Web
Top achievements
Rank 1
aban
Top achievements
Rank 1
Share this question
or