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;
}
}
}
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 -
If SelectionMode="Single" (Single is default value and you don't even need it), then remove both CheckBoxes and ShowCheckAll.
If CheckBoxes="true", then remove SelectionMode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With