Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I have a checkbox list in asp.net application. Now i need to know if there is an item that is selected which will be my basis for my IF/ELSE condition.

I need server-side validation here and not client-side.

Please help me!
Posted

1 solution

Hi,

Create a method that will return a Boolean value and name it as IsValid. The add the following codes in it.

C#
retval = false
foreach(ListItem chk in CheckBoxList1.Items)
{
   if(chk.Checked == false)
   {
      continue;
   }
   if(chk.Checked == true)
   {
      return true;
   }
}
return retval;


Regards,
Eduard
 
Share this answer
 
Comments
[no name] 13-Dec-11 20:32pm    
thank u for deducting 16 consecutive pts whoever u are! hater! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900