1

I have a radcombobox that has a checkbox before the item name.

here is my code.

<telerik:RadComboBox ID="cbx1" runat="server" Skin="Default" CheckBoxes="true" EmptyMessage="Sample">
                                <Items>
                                    <telerik:RadComboBoxItem Text="sample1" Value="1" />
                                    <telerik:RadComboBoxItem Text="sample2" Value="2" />
                                    <telerik:RadComboBoxItem Text="sample3" Value="3" />
                                    <telerik:RadComboBoxItem Text="sample4" Value="4" />
                                    <telerik:RadComboBoxItem Text="sample5" Value="5" />


                                </Items>
                            </telerik:RadComboBox>

how can i get the value of a multiple value of the combobox.

i tried using this code but it doesnt give me values.

if (cbx1.CheckedItems.Count > 0)
                {
                    strcbx = string.Empty;
                    foreach (var item in cbx1.CheckedItems)
                    {
                        strcbx = "'" + item.value + "'";
                    }
                }
StackOverflowUser
  • 305
  • 3
  • 8
  • 19

3 Answers3

0

Try this.

 string items = "";
    if (RadComboBox1.CheckedItems.Count>0)
    {
        foreach (RadComboBoxItem item in RadComboBox1.CheckedItems)
            items += item.Text+ ",";
    }
    Response.Write(items);``
Saritha.S.R
  • 800
  • 1
  • 6
  • 19
0
 if (cbx1.CheckedItems.Count>0)
            {
               string strcbx = string.Empty;
                foreach (var item in cbx1.CheckedItems)
                {
                    strcbx += "'" + item.value + "'" +",";
                }
                string listvalue = strcbx.TrimEnd(',');
            }
  • Hi, some explanations would significantly improve the quality of your answer – mrun Mar 03 '18 at 06:54
  • Hi, First check this checkbox item checked, then I declare a variable where store value from check box checked item, then i store value using foreach loop and separate value using "," finally i show value as a string without last comma. – Md Sabbir Shikder Mar 03 '18 at 07:16
0

If you want to get value with coma separate then use this code

string items = "";
items = string.Join(",", RadComboBox1.CheckedItems.Select(d => d.Value).ToArray())
Patrick
  • 1,189
  • 5
  • 11
  • 19