Forum Moderators: open

Message Too Old, No Replies

update problem in asp.net

         

priteshgupta

9:46 am on Nov 24, 2008 (gmt 0)

10+ Year Member



hi..
I am designing a website.In this,I needs to retrive values from database in a textbox(suppose I retrived value abc in textbox named textboxNewName) and after editing (changing the value to xyz) ,I need to update database with these new value on update button click.But when I am retriving the value in update button click using
dim newValue as string=textboxNewName.text 

then Instead of new value it is giving old value(abc).This thing i confirmed by debuging the code and also updatequery is running succussfully as it's return value is 1.

please suggest me what I am doing wrong. :tntworth:

mrMister

11:41 am on Nov 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would help if you posted your code.

In the first instace, are you populating the Textbox from the OnLoad event? If this is the case then you must realise that the onload event gets called before the onclick event. Like this...

1. Onload is called, and the texbox gets populated with "foo"

2. The user replaces the textbox with "bar" and presses the submit button causing a postback.

3 Onload is called, and the texbox gets populated with "foo"

4 Onclick is called and the database gets updated with the textbox contents ("foo")

You need to remove step 3, possibly by checking the Page.IsPostback method.

priteshgupta

11:58 am on Nov 24, 2008 (gmt 0)

10+ Year Member



ok..thanx buddy...first i will try for that and if problem doesnot solved ,then i will post code..