Textbox Losing Changes to Text on "Save"

I have a web form that is designed to take data from the user and store it in an SQL Database. The problem that I am having is that when I write out the SQL string to update the data to the database, the textbox.text property only shows the old value, and not the new value.

Here is the code where I write out the SQL String.
 Dim strSQL As String = "Update tblItem SET ItemDesc = '" & textbox.text & "' WHERE PDCode = '" & lblPDCode.Text & "'"
BluAvi8Asked:
Who is Participating?
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.

pwrBallCommented:
Check for Postback when loading the page and the fill the textbox with the old value
If Not Page.IsPostBack Then
fill the field with old data
0
sanjeewajCommented:
Bit of addtional thought on pwrBall's comment:

It appears that the data is loaded in the Page_Load and display in the UI.  However you save the data in a event handler such as a button click.  Since the Page_Load happens before click event, you always load the values to the UI from previous values.  Potentially you are saving back the old values.

A more safer place to load the data in such case is Page_PreRender.  At this stage all event handling and saving has finished and if you load data from the DB now, it is going to be the new values.

If this does not answer could you attach your code?
Sanjeewa Jayasinghe
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
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
ASP.NET

From novice to tech pro — start learning today.