Checkbox Validation Using SQL Code

Posted on 2011-10-17
Medium Priority
Last Modified: 2012-05-12
I am trying to run some VB validation code when a Checkbox (PrimaryAcct) is changed. The Checkbox appears as part of a Repeater and is bound to a field (CAddr_PrimaryAcct) on a SQL table. For the group of records displayed by the Repeater (based on the Repeater record source being filtered), I need to ensure that one and only one record has the CAddr_PrimaryAcct field checked.

For example: The Repeater is displaying 3 records and one of them has the PrimaryAcct Checkbox checked. If the user attempts to add a new record and checks the PrimaryAccount Checkbox, I want to produce an error message saying that a PrimaryAcct has already been selected.  

I know that I can use the OnCheckedChanged method of CheckBox to call the subroutine to do the validation, but how do I cancel the change to the Checkbox if I find that there is already a record with the field checked?
Question by:Donna Kainer
  • 2
LVL 18

Expert Comment

ID: 36986281
Why not run a SQL query when the page gets loaded to see if the PrimaryAcct has already been populated, if it has, then disable the CheckBox, if not, then the CheckBox is enabled.

Accepted Solution

Donna Kainer earned 0 total points
ID: 36986713
As usual, when I get the key words correct and with enough surfing of the web, I am able to eventually find the solution myself.

This time the answer was found while reading between the lines in http://weblogs.asp.net/gurusarkar/archive/2009/05/11/passing-value-to-an-oncheckedchanged-event-handler.aspx 

Author Closing Comment

by:Donna Kainer
ID: 37013516
I had to read between the lines but the solution referenced solved my problem.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question