Funny Behaviour -- Probably Easily Answered

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Funny Behaviour -- Probably Easily Answered

    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 Guest

  2. Similar Questions and Discussions

    1. already answered in crosspost
      Please do NOT start crossposting. John -- ---------------------------------------------------------------------------- ----------- RESOURCES...
    2. Funny behaviour of perfstat_disk()...
      On a customers machine, the function call: ndisks = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0); has started returning bogus data, i.e....
    3. Design Question -- DataList, Probably Easily Answered
      Hi Ron, Check out this article: http://www.developer.com/net/asp/article.php/2215041 I think it will get you going in the right direction. ...
    4. Easily answered firewire hub question
      No, my hardrive works fine. No, OS X didn't mysteriously crash. No, I don't need help with buggy software. I love my 15" Powerbook and it...
    5. funny printf behaviour in need of explanation
      Hi, i am attaching a snippet of code and two results that it produces. the first result is when the printf line is not commented out while the...
  3. #2

    Default Re: Funny Behaviour -- Probably Easily Answered

    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" <ron@razorvision.net> wrote in
    > news:bdcq38$9an@library2.airnews.net:
    >
    > > 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.
    > [url]http://www.crtimmonsinc.com/[/url]

    Ron Guest

  4. #3

    Default Re: Funny Behaviour -- Probably Easily Answered

    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" <ron@razorvision.net> wrote in message
    news:bdcq38$9an@library2.airnews.net...
    > 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. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139