Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Funny Behaviour -- Probably Easily Answered

Reply
Thread Tools

Funny Behaviour -- Probably Easily Answered

 
 
Ron
Guest
Posts: n/a
 
      06-25-2003
I am trying to gather data from various textboxes in a webform. Upon
loading, the form populates itself with values from a database. When the
Update button is pressed, the new values are loaded into an array and passed
to the data object.

The strange part is that when I pull the newly edited values from the
textboxes, the original values stick around. For example, I can change a
products name from "Fish Bait" to "Cat Food"... when I hit update, the value
will revert back to "Fish Bait".

I don't really know what the deal is, any suggestions?


 
Reply With Quote
 
 
 
 
Ron
Guest
Posts: n/a
 
      06-25-2003
Ahh, I knew it had to be something with the postback.

Thanks a lot, I appreciate your help

Ron
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xns93A59ADBC2733crtimmonscrtimmonsin@207.46.2 48.16...
> "Ron" <(E-Mail Removed)> wrote in
> news:bdcq38$(E-Mail Removed):
>
> > I am trying to gather data from various textboxes in a webform.
> > Upon loading, the form populates itself with values from a
> > database. When the Update button is pressed, the new values are
> > loaded into an array and passed to the data object.
> >
> > The strange part is that when I pull the newly edited values
> > from the textboxes, the original values stick around. For
> > example, I can change a products name from "Fish Bait" to "Cat
> > Food"... when I hit update, the value will revert back to "Fish
> > Bait".
> >
> > I don't really know what the deal is, any suggestions?

>
> Ron,
>
> It sounds like you may be incorrectly populating the textboxes in the
> Page_Load event.
>
> The standard way to do this is inside an "if (!this.IsPostBack)"
> block:
>
> if (!this.IsPostBack)
> {
> // Populate controls here.
> }
>
> If this isn't done, the controls will be repopulated every time the
> page is called.
>
> Hope this helps.
>
> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> http://www.crtimmonsinc.com/



 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      06-25-2003
I am guessing something about your code that might or might not be correct.

page_load
{
//populate text boxes from data base
}

update_click()
{
//put the new values into the database.
}

If this is the case, then when you click the update button, page_load runs
FIRST so they old values would be put into the textboxes from the database.

now when the update happens, the values might be the original values, since
you assigned them.

try putting your //populate textboxes from data base int

page_load
{
if ( !Page.IsPostBack )
{
//populate textboxes from data base.
}
}

This should fix all your problems, if it doesn't let me know.

HTH,

bill


"Ron" <(E-Mail Removed)> wrote in message
news:bdcq38$(E-Mail Removed)...
> I am trying to gather data from various textboxes in a webform. Upon
> loading, the form populates itself with values from a database. When the
> Update button is pressed, the new values are loaded into an array and

passed
> to the data object.
>
> The strange part is that when I pull the newly edited values from the
> textboxes, the original values stick around. For example, I can change a
> products name from "Fish Bait" to "Cat Food"... when I hit update, the

value
> will revert back to "Fish Bait".
>
> I don't really know what the deal is, any suggestions?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ Topic - I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? FAQ server Javascript 0 04-04-2007 11:00 PM
FAQ Topic - I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? FAQ server Javascript 7 02-10-2007 02:55 PM
FAQ Topic - I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? FAQ server Javascript 0 12-04-2006 12:00 AM
FAQ Topic - I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? FAQ server Javascript 0 10-06-2006 11:00 PM
FAQ Topic - I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? FAQ server Javascript 0 08-09-2006 11:00 PM



Advertisments