update checkbox values

Discussion in 'ASP .Net' started by Mike, Jun 2, 2004.

  1. Mike

    Mike Guest

    I have an update page with Checkbox's, how can I get the value of the
    checkbox and update the db table correctly?

    heres the snippet i'm trying to run and its not working

    strSQL = "update table1 set " & _
    if chActive.checked = true then
    "active='Yes'
    end if

    why will this not work?
     
    Mike, Jun 2, 2004
    #1
    1. Advertising

  2. Hi Mike,

    From the code you provided, you seems want to concate a certain sql
    statement string depend on some checkbox's value, yes?

    Your code is as
    ==================
    strSQL = "update table1 set " & _
    if chActive.checked = true then
    "active='Yes'
    end if
    ==================

    the above code may cause compile error due to syntax problems. We should
    change it as following
    Dim strSQL As String
    strSQL = "update table1 set"

    If chActive.checked = True Then

    strSQL = strSQL & "active='Yes'"

    End If


    Also, are you write the code directory in aspx file via <script
    runat=server>......</script> block rather than using code behind? I
    recommend that you use codebehind , that'll help avoid many syntax
    mistakes. In addition, here is the reference on processing the asp.net
    checkbox control's value in page code:

    http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGettingSettingCheckb
    oxWebControlValueProgrammatically.asp?frame=true

    Hope also helps. Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jun 2, 2004
    #2
    1. Advertising

  3. Mike

    Mike Guest

    not really the code below is actually part of an update SQL query. this is
    just the part were i have to update the check box values and enter either
    Yes or No in the DB depending if its checked or not

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Mike,
    >
    > From the code you provided, you seems want to concate a certain sql
    > statement string depend on some checkbox's value, yes?
    >
    > Your code is as
    > ==================
    > strSQL = "update table1 set " & _
    > if chActive.checked = true then
    > "active='Yes'
    > end if
    > ==================
    >
    > the above code may cause compile error due to syntax problems. We should
    > change it as following
    > Dim strSQL As String
    > strSQL = "update table1 set"
    >
    > If chActive.checked = True Then
    >
    > strSQL = strSQL & "active='Yes'"
    >
    > End If
    >
    >
    > Also, are you write the code directory in aspx file via <script
    > runat=server>......</script> block rather than using code behind? I
    > recommend that you use codebehind , that'll help avoid many syntax
    > mistakes. In addition, here is the reference on processing the asp.net
    > checkbox control's value in page code:
    >
    >

    http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGettingSettingCheckb
    > oxWebControlValueProgrammatically.asp?frame=true
    >
    > Hope also helps. Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    >
     
    Mike, Jun 2, 2004
    #3
  4. Hi Mike,

    Thanks for your followup. Does the CheckBox work ok now? I think you can
    test the CheckBox on a simple page to confirm it. Also, remember to enable
    the Page's ViewState. If you still have any questions, please feel free to
    post here. Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jun 3, 2004
    #4
    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. tshad
    Replies:
    0
    Views:
    532
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,407
    ThunderMusic
    Jan 25, 2006
  3. hazz
    Replies:
    1
    Views:
    5,603
  4. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    831
    David Wier
    Oct 6, 2006
  5. Joey Pang
    Replies:
    4
    Views:
    524
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page