Solved

Unable to get textbox to update with value from database

Posted on 2008-06-24
2
591 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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