4 Replies - 2120 Views - Last Post: 28 July 2010 - 02:19 PM Rate Topic: -----

#1 thursdayniac  Icon User is offline

  • D.I.C Regular

Reputation: 6
  • View blog
  • Posts: 255
  • Joined: 26-April 09

Saving Text Box Changes

Posted 28 July 2010 - 01:26 PM

I dont think I'll need to post any code for my question, but if anyone would like to see just let me know and I'll post.

Here's my problem:

I have a site with an EditAccount page. I have it to where the textboxes are filled with the user's existing account info on Page_Load(). The idea is that the user would simply change any textbox to what they want updated, and once they click "save", the database row gets updated with whatever is in the textboxes when they click "save"

The problem is that after I click "save", only what was originally in the textboxes gets saved to the DB...
it doesnt seem to recognized the changes made to the textboxes.

Does anyone know any C# methods or properties that can fix this?
Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Saving Text Box Changes

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Saving Text Box Changes

Posted 28 July 2010 - 01:31 PM

Moved to ASP.NET

When asking questions about ASP.NET please post them in the ASP.NET forum, even if you're using C# with ASP.NET :)
Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Saving Text Box Changes

Posted 28 July 2010 - 01:43 PM

I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.

To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.

FYI, the Page_Load method is executed on EVERY postback.

This post has been edited by eclipsed4utoo: 28 July 2010 - 01:44 PM

Was This Post Helpful? 3
  • +
  • -

#4 thursdayniac  Icon User is offline

  • D.I.C Regular

Reputation: 6
  • View blog
  • Posts: 255
  • Joined: 26-April 09

Re: Saving Text Box Changes

Posted 28 July 2010 - 01:47 PM

View Posteclipsed4utoo, on 28 July 2010 - 12:43 PM, said:

I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.

To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.

FYI, the Page_Load method is executed on EVERY postback.


K, you're right, I was missing that if statement. I just added it - will post back with results
Was This Post Helpful? 0
  • +
  • -

#5 thursdayniac  Icon User is offline

  • D.I.C Regular

Reputation: 6
  • View blog
  • Posts: 255
  • Joined: 26-April 09

Re: Saving Text Box Changes

Posted 28 July 2010 - 02:19 PM

View Postthursdayniac, on 28 July 2010 - 12:47 PM, said:

View Posteclipsed4utoo, on 28 July 2010 - 12:43 PM, said:

I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.

To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.

FYI, the Page_Load method is executed on EVERY postback.


K, you're right, I was missing that if statement. I just added it - will post back with results


It worked, thanks =)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1