I have the following code:
(some.aspx.cs)
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; }
(some.aspx)
<tr> <td>Food:</td> <td>Apple <input type="checkbox" name="food" id="apple" value="apple" runat="server" />Pizza <input type="checkbox" name="food" id="pizza" value="pizza" runat="server" />Orange <input type="checkbox" name="food" id="orange" value="orange" runat="server" /></td> </tr>
Now I am sending booleans to the SQL database. The problem is only untested . I mean, when you check some checkboxes, it sends it as true (and rightly so), but when I remove them, it remains the same (true).
Addition: Why too little? request here ... nothing special here
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...
the data type is bit .... I also tried with a string ... but without success
PS - I also tried with Request.Form ["apple"], and unchecking it worked ... but, unfortunately, the check is not ... when I check the box, it gives me an error:
Conversion failed when converting the varchar value 'on' to data type bit.
Is anyone
user350034
source share