Solved

Unable to get textbox to update with value from database

Posted on 2008-06-24
2
590 Views
Last Modified: 2008-07-21
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
Comment
Question by:kwienken
2 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
ID: 21863824
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
 

Author Comment

by:kwienken
ID: 21870576
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now