I have some checkboxes on my webapp, and a save button. When I click the save button, I save the checked
state of the checkboxes to the database.
When the checkboxes are not checked, I get 0
's in the database. However, when they are checked
, I get -1
's in the database. I was expecting 1
's. Are the -1
's normal for checked states?
Sample code:
Function ProcessAction(ByVal checkbox1 As Integer, ByVal checkbox2 As Integer) As Integer
connection = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
command = New SqlCommand("stored_procedure_name_here", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New SqlParameter("@id", SqlDbType.Int, 4)).Value = 100
command.Parameters.Add(New SqlParameter("@checkbox1", SqlDbType.Int, 4)).Value = checkbox1
command.Parameters.Add(New SqlParameter("@checkbox2", SqlDbType.Int, 4)).Value = checkbox2
command.Connection.Open()
command.ExecuteNonQuery()
command.Connection.Close()
Return 1
End Function
The call:
Sub ButtonClick(ByVal Source As Object, ByVal E As EventArgs)
ProcessAction(checkbox1.Checked, checkbox2.Checked)
End Sub