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 6123517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:01:35+00:00 2026-05-23T16:01:35+00:00

Possible Duplicate: Data not writing out to Database I’m trying to update a bit

  • 0

Possible Duplicate:
Data not writing out to Database

I’m trying to update a bit field in my database on a checkbox’s checkedchanged event. When it gets checked, it sends a 1. When it is unchecked, it sends a 0. Now I’m not sure why, but these changes only get saved SOME of the time. Would this have anything to do with the “!IsPostBack” ?

 protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
        {
            connection.Open();
            dataAdapter = new SqlDataAdapter("SELECT * FROM SecureOrders", connection);
            dataSet = new DataSet();             
            dataAdapter.Fill(dataSet, "SecureOrders");
            DataView source = new DataView(dataSet.Tables[0]);
            DefaultGrid.DataSource = source;
            DefaultGrid.DataBind();
            connection.Close();
        }
    }
}

protected void CheckBoxProcess_CheckedChanged(object sender, EventArgs e)
{
    bool update;
    string checkedString = "UPDATE SecureOrders SET processed = 1 WHERE fName LIKE '%" + DefaultGrid.SelectedRow.Cells[2].Text + "%' AND lName LIKE '% " + DefaultGrid.SelectedRow.Cells[3].Text + "%'";
    string uncheckedString = "UPDATE SecureOrders SET processed = 0 WHERE fName LIKE '%" + DefaultGrid.SelectedRow.Cells[2].Text + "%' AND lName LIKE '% " + DefaultGrid.SelectedRow.Cells[3].Text + "%'";
    CheckBox cb = (CheckBox)sender;
    GridViewRow gvr = (GridViewRow)cb.Parent.Parent;
    DefaultGrid.SelectedIndex = gvr.RowIndex;
    update = Convert.ToBoolean(DefaultGrid.SelectedValue);

    orderByString = orderByList.SelectedItem.Value;
    fieldString = searchTextBox.Text;



    connectionString = rootWebConfig.ConnectionStrings.ConnectionStrings["secureodb"];

    using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
    {
        connection.Open();
        SqlCommand checkedCmd = new SqlCommand(checkedString, connection);
        SqlCommand uncheckedCmd = new SqlCommand(uncheckedString, connection);

        if (cb.Checked == true)
        {
            checkedCmd.ExecuteNonQuery();

        }
        else
        {
            uncheckedCmd.ExecuteNonQuery();
        }

        connection.Close();
    }
  • 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-23T16:01:35+00:00Added an answer on May 23, 2026 at 4:01 pm

    I would recommend setting “EnableViewState” to false on your DataView, and then moving the code from the if (!IsPostBack) section to your page’s Pre_Init event. I think that will solve your problem and possibly also help your postbacks go faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: JavaScript data formatting/pretty printer I am getting a bit tired of looking
Possible Duplicate: What exactly does database normalization do? Can someone please clarify data normalization?
Possible Duplicate: Datatemplate inheritance I have several data types that are not subclasses, nor
Possible Duplicate: Core Data not saving NSString. Hey all! Currently experiencing a weird issue
Possible Duplicate: Associated model is not saving data when page is refreshed I have
Possible Duplicate: insert contacts into database but does not want to duplicate already existing
Possible Duplicate: AJAX- response data not saved to global scope? I basically have a
Possible Duplicate: Pass a data.frame column name to a function I am trying to
Possible Duplicate: Selecting data from two different servers in SQL Server How can I
Possible Duplicate: VS2008 Setup Project: Shared (By All Users) Application Data Files? Please can

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.