updating/new textbox values

I have a form which has standard txt boxes.

The txt boxes currently display data which is pulled down from a sql server.
when i try and update the txt boxes with new values the old one get re-inserted.

I have used breakpoints to test my code and at no point do the new values get detected.

My code is below
// My code for the Page_Load
 
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            audit check_user_registration = new audit();
 
            check_user_registration.Logon_Name = WindowsIdentity.GetCurrent().Name.ToString();
            check_user_registration.Stored_Procedure_Name = "dbo.select_user";
            users = check_user_registration.select_user();
 
            //If it is the first time a user has logged onto the audit web page they will have to entre their details.
            //The details are entered using the web form and submitted via the submit_new_user button.
            //If they have visited the audit web page before their user details will appear in 
            //the same text boxes but the submit_new_user button will not be visible.
            if (users.Tables[0].Rows.Count == 0)
            {
                submit_new_user.Visible = true;
            }
            else
            {
                //loop through dataset and place user details in text boxes.
                foreach (DataRow theRow in users.Tables[0].Rows)
                {
                    FirstNameText.Text = theRow["FirstName"].ToString();
                    SurnameText.Text = theRow["SurName"].ToString();
                    TelText.Text = theRow["Telephone"].ToString();
                    EmailText.Text = theRow["Email"].ToString();
                    Directorate_Derpartment_ServiceText.Text = theRow["Directorate_Derpartment_Service"].ToString();
                }
                //Since user data is present, they are now given the chance to edit their details.
                edit_user_data_button.Visible = true;
            }
 
            check_user_registration.Logon_Name = WindowsIdentity.GetCurrent().Name.ToString();
            check_user_registration.Stored_Procedure_Name = "dbo.select_records";
            users = check_user_registration.select_records();           
 
            if(!Page.IsPostBack)
            {
            user_records.DataSource = users;
            user_records.DataBind();
            }
 
        }
        catch
        { 
        
        }
    }
 
 
//My code for the button 
protected void edit_user_data_button_Click(object sender, EventArgs e)
    {
       
            audit_update_personal_details update = new audit_update_personal_details();
            update.First_Name1 = FirstNameText.Text.ToString();
            update.Sur_Name1 = SurnameText.Text.ToString();
            update.Directorate_Derpartment_Service1 = Directorate_Derpartment_ServiceText.Text.ToString();
            update.Telephone1 = TelText.Text.ToString();
            update.Email1 = EmailText.Text.ToString();
            update.Logon_Name1 = WindowsIdentity.GetCurrent().Name.ToString();
 
            update.Stored_Procedure_Name = "dbo.update_personal_details";
            update.update_personal_details();
 
    }

Open in new window

Mr_ShawAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pratima PharandeCommented:
Put your Page_Load code under Ispostback condition
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pratima PharandeCommented:
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
        if (!IsPostBack) {    
 audit check_user_registration = new audit();
 
            check_user_registration.Logon_Name = WindowsIdentity.GetCurrent().Name.ToString();
            check_user_registration.Stored_Procedure_Name = "dbo.select_user";
            users = check_user_registration.select_user();
 
            //If it is the first time a user has logged onto the audit web page they will have to entre their details.
            //The details are entered using the web form and submitted via the submit_new_user button.
            //If they have visited the audit web page before their user details will appear in
            //the same text boxes but the submit_new_user button will not be visible.
            if (users.Tables[0].Rows.Count == 0)
            {
                submit_new_user.Visible = true;
            }
            else
            {
                //loop through dataset and place user details in text boxes.
                foreach (DataRow theRow in users.Tables[0].Rows)
                {
                    FirstNameText.Text = theRow["FirstName"].ToString();
                    SurnameText.Text = theRow["SurName"].ToString();
                    TelText.Text = theRow["Telephone"].ToString();
                    EmailText.Text = theRow["Email"].ToString();
                    Directorate_Derpartment_ServiceText.Text = theRow["Directorate_Derpartment_Service"].ToString();
                }
                //Since user data is present, they are now given the chance to edit their details.
                edit_user_data_button.Visible = true;
            }
 
            check_user_registration.Logon_Name = WindowsIdentity.GetCurrent().Name.ToString();
            check_user_registration.Stored_Procedure_Name = "dbo.select_records";
            users = check_user_registration.select_records();          
 
            if(!Page.IsPostBack)
            {
            user_records.DataSource = users;
            user_records.DataBind();
            }
 }
        }
        catch
        {
       
        }

    }
0
Mr_ShawAuthor Commented:
thanks... u deserve a kiss  x
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.