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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:22:31+00:00 2026-06-04T02:22:31+00:00

I have a form in ASP.NET that loads data if it exists for the

  • 0

I have a form in ASP.NET that loads data if it exists for the user, and then allows them to update. So in Page_Load I have:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckAndAddRecord(_currentUser.UserID))
        {
            CreateEntryPoint(_currentUser.UserID);
        } 
        else
        {
            DataView dv = LoadApplicationData(_currentUser.UserID);
            foreach (DataRowView rowView in dv)
            {
                DataRow row = rowView.Row;

                _applicationId = row["id"].ToString();

                txtProjectNumber.Text = row["ProjectNumber"].ToString();
                  if (String.IsNullOrEmpty(chkSignedNDANo.ToString()) ||  String.IsNullOrEmpty(chkSignedNDAYes.ToString()))
                  {
                     chkSignedNDANo.Checked = Convert.ToBoolean(row["SignedNDAOnFile"]);
                     chkSignedNDAYes.Checked = Convert.ToBoolean(row["SignedNDAOnFile"]);
                  }
                  txtDateWritten.Text = row["DateWritten"].ToString();
            }
        }
    }

It calls this method:

    public bool CheckAndAddRecord(int UserId)
    {
        string connStr = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
        SqlConnection conn = new SqlConnection(connStr);
        SqlCommand cmd = new SqlCommand("CheckUserInTemp", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@SubmittedBy", UserId));
        SqlDataAdapter dap = new System.Data.SqlClient.SqlDataAdapter(cmd);
        DataSet ds = new DataSet();

        // open conn
        if (conn.State == ConnectionState.Closed)
            conn.Open();

        // fill
        dap.Fill(ds);

        // close the conn
        if (conn.State == ConnectionState.Open)
            conn.Close();

        bool boolRecordExist = false;

        if (ds.Tables[0].DefaultView.Count == 0)
        {
            boolRecordExist = false;
        } 
        else
        {
            boolRecordExist = true;
        }

        return boolRecordExist;
    }

This seems to work and populate the fields correctly. But then to update I call a Button click, which calls this method:

    public void UpdateRecordInTemp(int appId, string projectNumber)
    {
        string connStr = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
        SqlConnection conn = new SqlConnection(connStr);
        SqlCommand cmd = new SqlCommand("CPC_ProposalUpdateTemp", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@id", appId);
        cmd.Parameters.AddWithValue("@ProjectNumber", txtProjectNumber.Text);

        try
        {
            conn.Open();
            cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw new Exception("Exception adding coupon. " + ex.Message);
        }
        finally
        {
            conn.Close();
        }
    }

The problem is the fields passed always contain the old values. So if the value when entering the page is “123” and I change it to “abc” and click the button, “123” is passed instead of “abc”.

Sorry for the long post, I wanted to get all the details in. I am baffled by this. Thanks!

  • 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-04T02:22:33+00:00Added an answer on June 4, 2026 at 2:22 am

    At page Load check IsPostBack property in if. It seems that your code is executing on every page load.

    if(!IsPostBack)
    {
           // Do your work
    }
    

    UPDATE

    In your code method UpdateRecordInTemp(int appId, string projectNumber) you are not using projectNumber instead you are using txtProjectNumber.Text

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

Sidebar

Related Questions

I have an ASP.NET app that gets its data form an external service, via
I'm using ASP.Net/C# and I have a form that allows people to add information
I have an asp.net form that contains some html, 2 controls a calendar from
I have an ASP.NET MVC form that when submitted can return either an ActionResult
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have an asp.net web form (c#, .NET framework 3.5) that returns to itself
I have an ASP.NET 2.0 web form that is taking almost 30 seconds to
I have a web form in asp.net. I load the data on the page
I have an ajax form in asp.net mvc which is as simple as this:
I have a form within an ASP.NET MVC application and I'm trying to submit

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.