howto validate a checkboxlist

D

Dan

I tried using a customvalidator w/server validate function
and a requiredfieldvalidator to ensure one of the
checkboxes was checked in a checkboxlist.

I get this error:

Control 'ckbEchelonList' referenced by the
ControlToValidate property of 'valEchelonList' cannot be
validated.

I also noticed the pulldown to select controls to validate
in the IDE only shows textboxes and listboxes from my
page. So I'm thinking these validation controls can't
validate checkboxlists. Is this so? How do I make sure a
check occurs in a checkboxlist?
 
D

David

Maybe there is a better way, this works for me... Loop through all the
checkboxlist items, and if one is selected, return 'true'...

<code>
oneSelected = false;

for(int i=0; i < CheckBoxList.Items.Count; i++) {

if (CheckBoxList.Items.Selected)

oneSelected = true;

}

</code>
 

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

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top