Use the Data Text Field and Data Value Field properties to specify which field in the data source to bind to the properties of each list item in the control, respectively.The Check Box List control will now display the information from the data source.I've spent a couple of hours searching for a solution to validating a checkbox, since the Required Field Validator does not work with Checkboxes. Look for "skm Validators - custom validation controls for Check Boxes and Check Box Lists Actually I like to use AJAX for Checkbox validation, if you add the checkboxes inside an Update Panel and then on the server side you can check if they are check or not and update a red label by the checkbox.To the user, looks like works the same way the validation, for you, is just a little bit more magic to write.In this method I just loop through all the items of the Check Box List and if I find one that is selected then I return true.Now we have the validation working on the server after a postback, but it would be nice if we could perform the validation directly on the client when the user toggles the state of the checkboxes.
Below, I am showing a Java Script variable being set, that is for use by the Java Script method.
To accomplish this there is another step to take: inject some client side Java Script in the On Pre Render method.
The Pre Render event is raised just before the control is rendered on the page, so it the best moment to inject some client side functionality into the page.
$(source).parent() will get parent DOM element of the Custom Validator control that fired the Validate CBL function.
And then it finds any table that has an id ending with _Check Box List1.
I found a 2001 article on how to do that (Building a Check Box List Validator Control) but it doesn't work properly on ASP. So I have to make some small changes to make it work on ASP. First thing you have create a class that inherits from Base Validator In this we check if the control is null and if the control can be cast to a Check Box List.