Results 1 to 9 of 9

Thread: txtbox not updating

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    txtbox not updating

    this is in asp.net but I'm using the vb codebehind page to code:

    On the page load I use a datareader to populate the textboxes on my page. I let the user make changes then on a save click event I run an update. The value stays the same in the txtbox, even though I made changes to it. I debug thru and the value is indeed the same. Has anyone come across this problem?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Does the page get reloaded or refreshed in the meantime? Is AutoPostback set to True for the textbox?

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    To update the record, I'm going through a click event, so it looks like the page is being reloaded. The autopostback is set to false.

  4. #4

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    here's a more clearer picture of what is happending:

    this is how I fill my textboxs on the page_load

    Code:
    Do While objDataReader.Read = True
                    txtBidId.Text = objDataReader("Bid_ID")
                    txtBuyerName.Text = objDataReader("Buyer_Name")
                    txtIntDisStartDate.Text = objDataReader("display_start_date")
                    txtBidOpenDate.Text = objDataReader("bid_date")
                    txtBidDesc.Text = objDataReader("bid_schedule_desc")
                    txtIntDisEndDate.Text = objDataReader("display_end_date")
    then the user makes any changes they need and then on the save click event I have my update.


    Code:
    sqlCmd = "update pbss.pbss_bid_schedule "
            sqlCmd = sqlCmd & "set bid_date= to_date('" & txtBidOpenDate.Text & "','MM/DD/YYYY')"
            sqlCmd = sqlCmd & ",bid_status_code='" & Bid_Status & "'"
            sqlCmd = sqlCmd & ",pre_bid_ind=0,bid_schedule_desc='" & txtBidDesc.Text & "'"

    the problem I'm having is the textbox values are still holding the same values from when the datareader filled them up, even after changes have been made. I can see this when I debug

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Is the Do While Read part within an if Not PostBack block? If it isn't then it will be reran at postback.

  6. #6

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    That was the problem. I was clicking the save button and it was going trough the page_load event first and then the click event. So I used a If Not Me.IsPostBack() Then to check. How come the click event goes through the page_load? Is there a way to avoid that? Now I have to click twice to get to my click event..

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The click event forces the page to refresh, which then loads it again, and due to the way states work on webpages this causes the load event to fire. Luckily you have the IsPostBack function to see if its the first time or not.

  8. #8

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    any idea's as to why I have to click twice now to get to the click event?

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I'm not sure but what I think it is because you are changing the values in the click event which doesn't fire until after teh page_load event, which means that it needs another page load to actually display the changes. Try changing the button's AutoPostBack prop to True or just set a flag in the click event and make the actual changes in the load event if IsPostBack=True.

Posting Permissions

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



Click Here to Expand Forum to Full Width