update checkbox values

M

Mike

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?
 
S

Steven Cheng[MSFT]

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.)
 
M

Mike

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
 
S

Steven Cheng[MSFT]

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top