Solved

text field entry -- not updating string

Posted on 2007-11-25
5
175 Views
Last Modified: 2013-12-16
A bit puzzling ... is that I have a text entry field ::   TextBox.TestField  

as the aspx page load, there is db read of existing field data as follows:

if (rdr[0] != DBNull.Value)
    TextBox_TestField.Text = (string)rdr[0];

this works fine.

I edit that field, i.e. add / amend the field content.

Obviously want to save the amended details -- and then run a sql update scripte on that field... the sql update script is ok -- but the problem is that the TextBox_TestField does seemed to have changed -- so when posting to sql it keeps original loaded data, yet on-screen *web-page) I see the updated value.

Scatching my head on this one ... should be obvious to solve, but perhaps I need more caffeine !

Any help with this would be much apprieated.
0
Comment
Question by:amillyard
  • 2
  • 2
5 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 260 total points
ID: 20346656
can you show in which event you "update" the database?
and in which event you read it out to the text controls?
0
 

Author Comment

by:amillyard
ID: 20346676
Page_Load () -- for reading db content  (calls a db read procedure)

update starts from pressing 'update' button -- goes to a procedure which contains update routine.
0
 
LVL 19

Accepted Solution

by:
Limbeck earned 240 total points
ID: 20346685
do you check for a postback?

       if (!Page.IsPostBack)
        {
       //your code
       if (rdr[0] != DBNull.Value)
       TextBox_TestField.Text = (string)rdr[0];
       }
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 260 total points
ID: 20346701
then, that is the flaw.
when debugging, you will see that page_load comes BEFORE the button_click event.
you will have to skip in the page_load() any database reading when the page.IsPostback is true, and do it after the database update routine...

0
 

Author Comment

by:amillyard
ID: 20346738
wow - impressive, you are both 'spot on'.

added the :  if (!Page.IsPostBack) to isolate the page_load section.

I was getting slightly confused on this occassion with the postback I think -- as I was not using any obvious postback (i.e. drop-down lists requiring page refresh etc).

Just that once the db update was performed, there is a redirect command within the same procedure, which moves to another page automatically -- i.e.not refreshing the same page.

But, I think the point I need to understand from your advise that I should assume a postback is happening, even if not obvious.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now