mardi 26 janvier 2016

How to have values for a check box ( 0 or 1) based on if its clicked or not

This is my first time working with checkboxes (I know, LOL). I just wanted to know if it is possible for me to used a stored porcedure to insert into SQL, based on if the check box was ticked or not.

I have a public void function with parameters, one being "IsAdmin"

I add the parameter like this

cmd.Parameters.Add("@IsAdmin", SqlDbType.Int).Value = IsAdmin;

On my button, i just say the name of my function, and start adding the values. Now, if the checkbox is not ticked, the value will be 0. otherwise 1.

Is there some way to say "If ticked, then 1. Else 0."

(to call my function i just say InsertNewUser(). In between the brackets i have the values that will be added. Is this the correct way to insert the value? Help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire