validate CheckboxList

M

Mike

I have a checkboxList on my page and its required that at least item is
checked. Is there a way to validate that at least one is checked when the
user clicks the 'submit' button?
 
P

Peter Bucher [MVP]

Hi Mike
I have a checkboxList on my page and its required that at least item is
checked. Is there a way to validate that at least one is checked when the
user clicks the 'submit' button?
there is no out-of-the-box solution build in ASP.NET to do that.
but you can implement your own validator control, implementing from the
BaseValidator class,
or try whether a existing solution do the work for you (first two results):
- http://www.google.ch/search?hl=de&q=validating+checkboxlist&meta=
 
M

Mike

Peter,
I added a method to go through the checkbox list and if none was
selected return false, else true, then I added my data if it was true
something like this;

public bool isChecked()
{
bool chkBox= false;
for (int i = 0; i <= (chkList.Items.Count - 1); i++)
{
if ((chkList.Items.Selected))
{
chkBox = true;
}
}
return chkBox;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top