Funny Behaviour -- Probably Easily Answered

Discussion in 'ASP .Net' started by Ron, Jun 25, 2003.

  1. Ron

    Ron Guest

    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, Jun 25, 2003
    #1
    1. Advertising

  2. Ron

    Ron Guest

    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.248.16...
    > "Ron" <> wrote in
    > news:bdcq38$:
    >
    > > 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/
     
    Ron, Jun 25, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:bdcq38$...
    > 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?
    >
    >
     
    William F. Robertson, Jr., Jun 25, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    1,048
  2. Banibrata Dutta
    Replies:
    3
    Views:
    252
  3. Edvin Fuglebakk

    funny generator behaviour

    Edvin Fuglebakk, Dec 4, 2008, in forum: Python
    Replies:
    5
    Views:
    304
    Arnaud Delobelle
    Dec 4, 2008
  4. Mattsteel
    Replies:
    4
    Views:
    382
    Mattsteel
    Jan 30, 2010
  5. Jeremy Henty
    Replies:
    7
    Views:
    124
    Jeremy Henty
    Jun 5, 2006
Loading...

Share This Page