Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

text field entry -- not updating string

Posted on 2007-11-25
5
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 1040 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 960 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 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 1040 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

647 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