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

Is it possible to set multiple RadComboBoxItems as selected in code behind?

1 Answer 231 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Philip Jones
Top achievements
Rank 1
Philip Jones asked on 06 Jun 2012, 02:35 PM

I’m using a RadComboBox where a user can select multiple items and save them against a news article.

When the user visits back I need to be able to pre-populate all of the items which were previously saved against the article.

I’m trying to work out how to set multiple items as selected, from what I can see you can only ever set one.

Something like this:

RadComboBoxItem _item1 = new RadComboBoxItem();
_item1.Value = "1";
_item1.Text = "One";
_item1.Selected = true;
RadComboBoxItem _item2 = new RadComboBoxItem();
_item2.Value = "2";
_item2.Text = "Two";
_item2.Selected = true;
RadComboBox _radComboBox = new RadComboBox();
_radComboBox.Items.Add(_item1);
_radComboBox.Items.Add(_item2);

Thank you!!

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jun 2012, 04:33 AM
Hi,

You can use a RadCombobox with checkboxes to select multiple items. Here is the sample code which I tried.

C#:
RadComboBoxItem _item1 = new RadComboBoxItem();
_item1.Value = "1";
_item1.Text = "One";
_item1.Checked = true;
RadComboBoxItem _item2 = new RadComboBoxItem();
_item2.Value = "2";
_item2.Text = "Two";
_item2.Checked = true;
RadComboBox _radComboBox = new RadComboBox();
_radComboBox.CheckBoxes = true;
_radComboBox.Items.Add(_item1);
_radComboBox.Items.Add(_item2);

Thanks,
Princy.
Tags
ComboBox
Asked by
Philip Jones
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or