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

2 posts, 0 answers
  1. Philip Jones
    Philip Jones avatar
    7 posts
    Member since:
    Dec 2005

    Posted 06 Jun 2012 Link to this post

    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!!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Jun 2012 Link to this post

    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.
Back to Top