I've got a form prepopulated from a row in a database (grabs the querystring from the URL to determine the row) and this works fine. I'm using the pageload function on the code-behind file to do this.

The button onclick has a function that is supposed to take the data from the form and put it back to the database. Here's that code:

using (SqlConnection updater = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ToString()))
                string up = "UPDATE roomtable SET ";
                up += "name='" + namein.Text.ToString() + "', country='" + countryin.Text.ToString() + "', state='" + statesin.Text.ToString() + "' ";
                up += "WHERE rid=" + curid;
                //curid is already declared and correct

                SqlCommand finalupdate = new SqlCommand(up);
                finalupdate.Connection = updater;

However, when I replace the form.Text.ToString() with hardcoded data, it will work after TWO clicks of the button. The first click will refresh the page (and the data on all of form elements) and the second click will apply the hardcoded changes to the database.

Any ideas on what I am doing wrong?
Thank you!!