locked
My check box always submits "Yes"? RRS feed

  • Question

  • User-1605942155 posted

    I have a checkbox that I have setup to send in a Yes or No value. It was working a while back but for some reason it's only submitting Yes now. 

    <asp:CheckBox ID="cbAdminUser" runat="server" />

    Dim strAdminUser As String = ""
    
            If cbAdminUser.Checked = False Then
                strAdminUser = "No"
            ElseIf cbAdminUser.Checked = True Then
                strAdminUser = "Yes"
            End If
    
    		Dim strConnString As String = ConfigurationManager.ConnectionStrings("snfTimeSystemConnectionString").ConnectionString
                Dim con As New SqlConnection(strConnString)
                Dim cmd As New SqlCommand()
                cmd.CommandType = CommandType.StoredProcedure
                cmd.CommandText = "AddPrac"
                
    			cmd.Parameters.Add("@AdminUser", SqlDbType.VarChar).Value = strAdminUser
    
                cmd.Connection = con
    
                con.Open()
                cmd.ExecuteNonQuery()
                lblMessage.Text = "Success!!"
    
                con.Close()
                con.Dispose()

    Thanks in advance!

    Thursday, March 10, 2016 11:29 PM

Answers