?
Solved

text field entry -- not updating string

Posted on 2007-11-25
5
Medium Priority
?
185 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 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