Rookie Question

Discussion in 'ASP .Net' started by Big E, Jun 17, 2004.

  1. Big E

    Big E Guest

    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
     
    Big E, Jun 17, 2004
    #1
    1. Advertising

  2. Big E

    GSK Guest

    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.

    "Big E" <> wrote in message
    news:OXaLn9$...
    > 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
    >
    >
     
    GSK, Jun 17, 2004
    #2
    1. Advertising

  3. Big E

    avnrao Guest

    Convert.ToInt16(checkbox.checked) returns 1 or 0.

    Av.
    "Big E" <> wrote in message
    news:OXaLn9$...
    > 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
    >
    >
     
    avnrao, Jun 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Smith

    Rookie question

    Greg Smith, Oct 7, 2005, in forum: Java
    Replies:
    4
    Views:
    364
    Monique Y. Mudama
    Oct 8, 2005
  2. Ian
    Replies:
    4
    Views:
    392
    Ian Rutgers
    Jan 22, 2005
  3. Don Bruder
    Replies:
    12
    Views:
    572
    Duncan Booth
    Sep 26, 2003
  4. Steve D. Perkins

    Rookie question about data types (hashtables)

    Steve D. Perkins, Jan 29, 2004, in forum: Python
    Replies:
    7
    Views:
    382
    Rainer Deyke
    Jan 29, 2004
  5. Brett
    Replies:
    4
    Views:
    390
    Dennis Lee Bieber
    Apr 15, 2005
Loading...

Share This Page