Check whether the checkbox is checked or not - ASP.NET
<p>I have the following code:</p>

<p>(some.aspx.cs)</p>

<pre><code>        if(Page.IsPostBack)
        {
        bool apple2 = false;
        bool pizza2 = false;
        bool orange2 = false;
        if (apple.Checked)
            apple2 = true;
        if (pizza.Checked)
            pizza2 = true;
        if (orange.Checked)
            orange2 = true;
        }
</code></pre>

<p>(some.aspx)</p>

<pre><code>     &lt;tr&gt;
     &lt;td&gt;Food:&lt;/td&gt;
     &lt;td&gt;Apple &lt;input type="checkbox" name="food" id="apple" value="apple" runat="server" /&gt;Pizza &lt;input type="checkbox" name="food" id="pizza" value="pizza" runat="server" /&gt;Orange &lt;input type="checkbox" name="food" id="orange" value="orange" runat="server" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
</code></pre>

<p>Now, i send the Boolean variables to SQL database. The problem is only with <strong>unchecked</strong> boxes. I mean, when you check some checkboxes it sends it as true (and that's right) but when i uncheck them it remains the same (true).</p>

<p>Addition:
Why too little? 
here's a query...nothing special here</p>

<pre><code>string q = string.Format(@"UPDATE tblUsers SET ......., apple='{8}', orange='{9}' WHERE id='{10}'", ...., apple2, orange2, id);
lib.sql_query(q); // using my sql library...
</code></pre>

<p>the datatype is bit....i tried also with string...but no success</p>

<p>P.S. - i also tried with Request.Form["apple"], and the uncheck worked...but unfortunately the check didn't...when i check the checkbox it throws me an error: </p>

<pre><code>Conversion failed when converting the varchar value 'on' to data type bit. 
</code></pre>

<p>Somebody?</p>
