Error with loading and updating form data
<p>I have a form in ASP.NET that loads data if it exists for the user, and then allows them to update. So in <code>Page_Load</code> I have:</p>

<pre><code>    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();
            }
        }
    }
</code></pre>

<p>It calls this method:</p>

<pre><code>    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;
    }
</code></pre>

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

<pre><code>    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();
        }
    }
</code></pre>

<p>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".</p>

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