Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Checked checkbox in the RadListBox (telerik)

I am using RadListbox (Telerik) with checkbox. I want to get checked checkbox value from the listbox in the server side, please give best practice solution :

My code is : Aspx :

 <telerik:RadListBox ID="rlbSecurity" runat="server"  CheckBoxes="true"  
                ShowCheckAll="true" Width="100%" SelectionMode="Single" 
                Skin="Office2010Silver" ></telerik:RadListBox>

Code Behind :

 string selectedCollateralId=string.Empty;
            if (rlbSecurity.Items.Count > 0)
            {
                for (int i = 0; i < rlbSecurity.Items.Count; i++)
                {
                    if (rlbSecurity.Items[i].Checked)
                    {
                         selectedCollateralId = rlbSecurity.Items[i].Value;

                    }
                }
            }

1 Answers

You have CheckBoxes="true" and SelectionMode="Single". It doesn't make sense.

The reason of displaying CheckBoxes is you allow user to select multiple items.

You have two options -

  1. If SelectionMode="Single" (Single is default value and you don't even need it), then remove both CheckBoxes and ShowCheckAll.

  2. If CheckBoxes="true", then remove SelectionMode.

like image 88
Win Avatar answered Dec 15 '25 16:12

Win