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

  • SEARCH
  • Home
  • 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 8743983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:46:18+00:00 2026-06-13T11:46:18+00:00

From my previous post I’m using a javascript to check some checkboxes which works

  • 0

From my previous post I’m using a javascript to check some checkboxes which works fine. But then I have a button that puts some records in a database. Using the following code it doesn’t matter whether a checkbox is checked or not it is always gives me false.

        bool first = true;
        bool _IsPhone = false;
        bool _IsLotus = false;
        bool _IsRelationship = false;
        bool _IsAdmin = false;
        string _Country;

        foreach (GridViewRow row in CountryAccessGrid.Rows)
        {
            CheckBox ch = ((CheckBox)row.FindControl("chkPhones"));

            _Country = ((Label)row.FindControl("lblCountryShort")).Text;
            _IsPhone = ((CheckBox)row.FindControl("chkPhones")).Checked;
            _IsLotus = ((CheckBox)row.FindControl("chkLotus")).Checked;
            _IsRelationship = ((CheckBox)row.FindControl("chkRelationship")).Checked;
            _IsAdmin = ((CheckBox)row.FindControl("chkIsAdmin")).Checked;

            if (_IsPhone == true || _IsLotus == true || _IsRelationship == true || _IsRelationship == true || _IsAdmin == true)
            {
                cntr = cntr + 1;

                if (!first)
                {
                    insertaccess += " UNION ALL ";
                }
                insertaccess += " SELECT " + _UserID + ", '" + _Country + "', " + _IsPhone + ", " + _IsLotus + ", " + _IsRelationship + ", " + _IsAdmin;

                first = false;
            }
        }

How to get a state of a checkbox, please?

  • 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-06-13T11:46:19+00:00Added an answer on June 13, 2026 at 11:46 am

    To be able to asnwer this question we have to know following:

    • from where is this code
    • what is the DataSource
    • where/when do you DataBind it to the GridView?

    But i assume that you always DataBind it in Page_Load even if it’s a postback. That would override the values and prevents the events from being triggered.

    So you have to use the IsPostBack property:

    private void Page_Load()
    {
        if (!IsPostBack)
        {
            DataBindGridView();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried switching from a previous Post request to a Get request. Which
Sorry but yet another question on JavaScript. From my previous post, I was able
I thought I had this answered from a previous post, but I still can't
My project requirements has changed from my previous post . I now have a
Taken from a previous post with some modifications to respond to sepp2k 's comment
As some of you may of seen from my previous post I'm new to
Further to my previous post about obtaining data from objects on the server using
From this previous post I have this code: @model SuburbanCustPortal.Models.AddCustomerModel @{ ViewBag.Title = Add
According to my previous post I am trying to get back some information from
I have this function from a plugin (from a previous post) // This method

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.