• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

Unable to get textbox to update with value from database

I have a cart view page that has a quantity text box control for each product in the cart. There is an update hyperlink next to each quantity text box that triggers an asyncpostback. The cart contents is in an update panel and builds on page load. The update to the database takes place in the page load only on an asyncpostback and prior to the cart contents being pulled from the database and rendered. The quantity updates properly in the database and all totals update in the cart contents table but the quantity textbox keeps the user entered  value.

I only realized this because if a user enters say -5 for a quantity then I change the quantity to one and display a message stating that the quantity was invalid. The database gets updated to quantity of 1, all totals show correct pricing, and if I generate a new textbox under the original one it gets a value of 1 but the -5 remains in the original text box.

Any suggestions?
0
kwienken
Asked:
kwienken
1 Solution
 
naspinskiCommented:
you have to explicitly change the textbox, it will not rebind to data unless you specify that it must.  Or you could just put the new value in there when you test for validity.
0
 
kwienkenAuthor Commented:
The problem is that it's not bound to a data source. It should be but I didn't how to in this instance. I've fixed my problem for now by adding a random number to the text box ID. I would still like to know why TextBox.Text = newValue doesn't change what the user sees after an AsyncPostBack though.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now