Groups | Blog | Home
all groups > asp.net > may 2004 >

asp.net : getting modified text box values


Mark
5/10/2004 11:37:30 PM
Hi,
I have an aspx page, that in the PageLoad sub, gets values from a specific
record in a database as where the record id is retrieved from the
querystring. Thesee values are then used to populate a series of text boxes,
radio button selections and drop down list selections. This all works.

I run into a problem when I change the values of one of these populated
items. When a button is clicked to update the database with the modified
data, the event fires, but the data is not updated. If I hard code string
data in, instead of using the data from the textboxes (or drop list or radio
button), the changes appear in the database as expected.
Why are the changes to the text box data not appearing in the db, and how
can I fix this?


TIA,
Mark

Ken Cox [Microsoft MVP]
5/11/2004 12:15:21 AM
Hi Mark,

It is hard to diagnose without seeing your code, but have you remembered to
use "if not ispostback" in the Load event? You don't want to keep filling
the textbox with the original value.

Ken

[quoted text, click to view]
Warren J. Hairston
5/11/2004 12:16:40 AM
It sounds like your page is resetting the values to the original data from
the database on PostBack. Is the code that initializes everything executing
each time Page_Load is called, or just during the initial Page_Load?
Remember, Page_Load gets called once when the page initially loads, once
during each PostBack.

Make sure your initialization code in Page_Load is wrapped in the following
(if you're using C#):

if (!IsPostBack) //not in PostBack
{
....
}




[quoted text, click to view]

Mark
5/11/2004 8:21:09 AM
Ooops..... I think that'll do it.........
compltely slipped my mind.

Thank you both for the kick in the pants ;-)


[quoted text, click to view]

AddThis Social Bookmark Button