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

How to check that at least one item is selected

2 Answers 566 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jesper
Top achievements
Rank 1
Jesper asked on 27 Oct 2011, 08:17 AM
Hi,
how to check that at least one item is selected in a RadComboBox? My RadComboBox allows just single selection and I want to check that user has selected one item which is needed for next/related user input control (RadListBox) will be loaded with data (from code behind). Meaning I will check that at least one item is selected from code behind method RadComboBox_SelectedIndexChanged and if one item is checked load data into next/related RadListBox.

Why isn't there a method RadComboBox.SelectedItems.Count as there is for example RadListBox?

I have EmptyMessage set to '--- Select ---' in RadComboBox. Can I use this in some way?

Rgds,
Jesper 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Oct 2011, 09:52 AM
Hello Jesper,

You can try the following for getting the count of selected items.

C#:
  protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
 int count = RadComboBox1.SelectedValue.Length;
}

Thanks,
Princy.
0
Jesper
Top achievements
Rank 1
answered on 27 Oct 2011, 10:13 AM
Hi Princy,
did it... Thx

if (RadComboBox1.SelectedValue.Length > 0)
{
...
}

Regards,
Jesper
Tags
ComboBox
Asked by
Jesper
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jesper
Top achievements
Rank 1
Share this question
or