Jump to content
Xtreme .Net Talk

asp:checkbox insert a "1" or "0" for true or false HELP!


Recommended Posts

Posted

I need to have an asp:checkbox place a "1", when it is checked, in a field in my sql server database or place a "0" when it is not checked.

 

I started with this:

 

Sub DoQuarterlyOverWrite(sender As Object, e As EventArgs)

 

If Quaterly.Checked=true Then

Quarterly.checked = "1"

Else

Quarterly.Checked = "0"

End If

 

End Sub

 

I need to use this SQL insert because that is what the older developer used for this page.

 

dim Cmd as new SQLCommand("InsertNewGrant",conn)

 

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@GrantNumber", GrantNumber.Text.Trim())

cmd.Parameters.Add("@GrantProjectName", ProjectName.Text.Trim())

cmd.Parameters.Add("@CountryId", Country.SelectedItem.Value)

cmd.Parameters.Add("@Description", 0)

cmd.Parameters.Add("@CreateUserId", lblLoggedInAsId.text.Trim())

cmd.Parameters.Add("@UpdateUserId", 0)

cmd.Parameters.Add("@ObligationDate", ObligationDate.SelectedDate)

cmd.Parameters.Add("@OrigionalExpDate", CurrentExpirationDate.SelectedDate)

cmd.Parameters.Add("@CurrentExpDate", CurrentExpirationDate.SelectedDate)

cmd.Parameters.Add("@Terminated", 0)

cmd.Parameters.Add("@Suspended", 0)

cmd.Parameters.Add("@Locked", 0)

cmd.Parameters.Add("@LockedByUserId", 0)

cmd.Parameters.Add("@ACTNumber", 0)

cmd.Parameters.Add("@GranteeName", GranteeName.Text.Trim())

cmd.Parameters.Add("@GranteeAddress1", AddressLine1.Text.Trim())

cmd.Parameters.Add("@GranteeAddress2", AddressLine2.Text.Trim())

cmd.Parameters.Add("@GranteeAddress3", AddressLine3.Text.Trim())

Cmd.connection.open()

Cmd.ExecuteNonQuery()

Cmd.connection.close()

 

 

Help! :confused: :confused: :confused: :confused:

Posted

the Stored Procedure needs to be modified so it takes int a @Quarterly parameter and the insert statment needs to insert this value. Then you need to add this paramter into your command object. Also, your if statment should look something like this..

 

If Quartherly.Checked Then

cmd.Parameters.Add("@Quarterly", 1)

Else

cmd.Parameters.Add("@Quarterly", 0)

Enf If

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...