Home All Groups Group Topic Archive Search About

TextBox.Text not getting the proper value

Author
20 May 2005 4:36 PM
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.

Author
20 May 2005 6:09 PM
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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net



Show quoteHide quote
"daiski" <dai***@gmail.com> wrote in message
news:1116607019.551690.158130@g47g2000cwa.googlegroups.com...
> 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.
>
Author
21 May 2005 7:29 PM
daiski
Worked like a charm :)  Thanks Steve.