Question triggering a SP from web


New member
Feb 4, 2015
Programming Experience
Not sure if this is the correct forum for this, but I will try anyway. Hopefully I can phrase my question properly. Here is what I am attempting to accomplish:

I would like to use a checkbox value to be sent as a parameter to a SP when the submit button is clicked. The problem I am running into is that the checkbox by default will return the value of 'on' when checked and 'NULL' when not checked. This would be fine if the DB field was a string type, but it is not, it is an Int. (yes I know binary would be more appropriate, but it is not my DB and I can' change it). So my issue is one of converting the output of the checkbox to '1' if checked and either 'NULL' or '0' if not checked. I have a Var statement that does the conversion, but I think I am missing some fundamental step as the Var output is not being passed to the SP, just the default string output of the checkbox is. Here is the entirety of the web page. As it is it works as long as on my test DB I set the 'Valid' field to a string type.

So my question is actually two-fold, as there may be more than one way to solve this. What is wrong with my code that the Var statements output is not getting passed to the SP? or, can I convert the string output of the checkbox in the SP?

<%@Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">
private void InsertCard (object source, EventArgs e) {

string checkBoxValue = this.CheckBox1.Checked ? "1" : "0";

<html xmlns="" >
<head runat="server">
<title>ASP.NET Example</title>
<form id="form1" runat="server">

connectionstring="<%$ ConnectionStringsevTestConnectionString %>"
insertcommand="AddMember" InsertCommandType="StoredProcedure">
<asp:FormParameter Name="CardNumber" formfield="CardNumberBox" Type="int32" />
<asp:FormParameter Name="NameFirst" formfield="NameFirstBox" Type="String" />
<asp:FormParameter Name="Valid" formfield="CheckBox1" Type="string" />

<br /><asp:textbox
runat="server" />

<br /><asp:textbox
runat="server" />

<br />

<asp:CheckBox id="CheckBox1" Text="Valid" runat="server" />

<br />
text="Add Card"
onclick="InsertCard" />

Top Bottom