Rookie Question

  • Thread starter Thread starter Big E
  • Start date Start date
B

Big E

I'm using ASP.Net and SQL Server.
In the database I have a bit field.
On the webform I have a checkbox.
When I do a insert or update I want the checkbox to equal the bit field.
When I do a checkbox1.Text it equals nothing "".
When I do a checkbox.checked it equals True or False.
How can I have it equal 0 or 1

Thanks.

Erik
 
If using a stored procedure, simply send the value (boolean) of
checkbox1.checked. MSSQL will convert it to a bit. This is if you are
updating or inserting data from a form.

If you are creating your SQL within the code-behind (not recommended), then
you may have to use a simple if statement to convert your checkbox.checked
to a '1' or '0'.

If you are populating your form from contents in the database, try setting
checkbox.checked to Boolean.Parse(<data value>). There are other methods for
converting to a boolean as well I believe.

- gsk.
 
Back
Top