|
-
Dec 17th, 2002, 02:20 PM
#1
Thread Starter
Frenzied Member
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?
-
Dec 17th, 2002, 03:11 PM
#2
Does the page get reloaded or refreshed in the meantime? Is AutoPostback set to True for the textbox?
-
Dec 18th, 2002, 08:41 AM
#3
Thread Starter
Frenzied Member
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.
-
Dec 18th, 2002, 08:53 AM
#4
Thread Starter
Frenzied Member
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
-
Dec 18th, 2002, 11:18 AM
#5
Is the Do While Read part within an if Not PostBack block? If it isn't then it will be reran at postback.
-
Dec 18th, 2002, 01:12 PM
#6
Thread Starter
Frenzied Member
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..
-
Dec 18th, 2002, 01:41 PM
#7
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.
-
Dec 18th, 2002, 01:45 PM
#8
Thread Starter
Frenzied Member
any idea's as to why I have to click twice now to get to the click event?
-
Dec 18th, 2002, 02:00 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|