TextBox.Text not getting the proper value

D

daiski

Hi.

I have a form that is used to edit a row from SQL. The form textboxes
are filled at page_load so that the user can see the data. User can
make changes in the textboxes then click a button that uses SQL
connection and UPDATE statement to save in DB.

The problem is that textbox.text (in the code behind) is still getting
the original data that was filled in from page_load.

Any ideas why?? Appreciate it.

* I used VS.Net debugger and added a watch on the textbox.text to see
that this is a problem with my asp and not with my sql implementation.
 
S

Steve C. Orr [MVP, MCSD]

Perhaps you are setting the value from the database every time the page is
requested.

1. You set the textbox value (from the database) to "Test" in the Page_Load
event.
2. The user enters a new value
3. The page posts back
4. You set the textbox value (from the database) to "Test" in the Page_Load
event.
5. The button click event is called, and you save the value (now "Fred"
again) to the database.

To avoid this you should load the data from the database only when
Page.IsPostback=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top