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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:08:55+00:00 2026-06-14T20:08:55+00:00

I have a form which is filled with values retrieved from database. That form

  • 0

I have a form which is filled with values retrieved from database. That form has a submit button which should update the corresponding fields in the database once clicked.

The problem is that no matter what I do the values do not get updated in the database. I’m using a stored procedure and checked it twice, it works ok, I also tried the trick with the hardcoded insert value-also works.

My guess is that once the field is populated from the database on Page_Load, its value remains even if I change it. How do I overcome this issue so that I can use the same form to retrieve and update data?

 protected void Page_Load(object sender, EventArgs e)
    {
        lblMsg.Visible = false;

        string bookingid = Request.QueryString["bookingid"];
        Booking b = BookingAccess.GetBooking(Int32.Parse(bookingid));
        if (b != null)
        {
            var start_date_formatted = ((DateTime)b.StartDate).ToString("dd-MM-yyyy");
            var end_date_formatted = ((DateTime)b.EndDate).ToString("dd-MM-yyyy");

            pet_name.Text = b.PetName;
            species.Text = b.Species;
            start_date.Text = start_date_formatted;
            end_date.Text = end_date_formatted;
        }


    }

    protected void btnEditBooking_Click(object sender, EventArgs e)
    {
        string bookingid_raw = Request.QueryString["bookingid"];
        int bookingid = int.Parse(bookingid_raw);

        var start_date_formatted = DateTime.ParseExact(start_date.Text, "dd-MM-yyyy", null);
        var end_date_formatted = DateTime.ParseExact(end_date.Text, "dd-MM-yyyy", null);

        string pet_name = "a";
        string species = "b";
        lblMsg.Visible = true;
        string msg = BookingAccess.UpdateBooking(bookingid, pet_name, species, start_date_formatted, end_date_formatted);
        if (msg == null)
            lblMsg.Text = "Updated booking details successfully!";
        else
            lblMsg.Text = "Error -> " + msg;
    }
  • 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-14T20:08:56+00:00Added an answer on June 14, 2026 at 8:08 pm

    If you have your data load in the Page_Load function, ensure that you are checking for IsPostBack to ensure that you do not reset the data when the user submits the page.

    private void Page_Load()
    {
        if (!IsPostBack)
        {
            // Load the data from database
        } else {
            // Validate the data and save to database
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created an app which contains form and that have to filled up in
I have a form which has fields pre-filled with a default value, like this:
I have several DropDown controls on a Web Form which are filled using AJAX
I have a form which has a RichTextBox docked to the left and DataGridView
I have a form which has three inputs when the page loads -- 2
I have a popup form with 4 textboxes, all of which have default values
In simple terms I have a form which has three identical entry fields. The
I am creating a form which has many dynamic dropdown.. values selected in first
I have a form which writes to a MySQL database. For example: Employee Number:
I have a form which is used as an interface for CRUD on database

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.