Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:23:42+00:00 2026-05-15T01:23:42+00:00

I have the following code: (some.aspx.cs) if(Page.IsPostBack) { bool apple2 = false; bool pizza2

  • 0

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 send the Boolean variables to SQL database. The problem is only with unchecked 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).

Addition:
Why too little?
here’s a query…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 datatype is bit….i tried also with string…but no success

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:

Conversion failed when converting the varchar value 'on' to data type bit. 

Somebody?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:23:43+00:00Added an answer on May 15, 2026 at 1:23 am

    So after a long time of combinations and other stuff it worked…Without any javascripts and hidden fields…
    that’s the .cs code

            bool apple2 = (Request.Form["apple"] == "on") ? true : false;
            bool orange2 = (Request.Form["orange"] == "on") ? true : false;
            bool pizza2 = (Request.Form["pizza"] == "on") ? true : false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to validate some fields on a sharepoint newform.aspx. To
i have some header tabs on a basic index.aspx page that uses a masterpage.
I have the following code in my aspx code-behind and it works fine. Because
I have the following ASPX code: <asp:ScriptManager ID=ScriptManager1 runat=server /> <asp:UpdatePanel runat=server ID=UpdatePanel UpdateMode=Conditional>
I have some JavaScript that is sharing a request between two separate servers on
I am having some issues with deploying my MVC 2 application on a IIS
I have an XSLT transform I am using to process an XML file, inserting
I have a DotNetNuke website that by default people use anonymously. When they want
I have a sharepoint site and want to create a script for links with
Please forgive any short-comings in this question; flash is not my area of expertise,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.