Updating dataset with values from TextBox control

P

Paul Aspinall

Hi
I have built a very simple page, which takes data via TextBox controls, and
updates to a Dataset.

I've used the Data Access Blocks (v2), to help with functionality, and to
build a DAL.

Part of my code takes the form:

ds.tables(0).rows(0)("FirstName") = Firstname.Text


There is only one record in the dataset, so this updates the record with the
value the user entered in the TextBox.
However, it doesn't.....

When I debug, the value of Firstname.Text is the value it was when the page
opened, and not the value that is Currently in it.

I have changed the code to :

ds.tables(0).rows(0)("FirstName") = "Test Value"

And this gets wrote out successfully.

It appears that my textbox does not update its value, when the user changes
its value.
Seems strange.... Am I doing something wrong?

Thanks


Paul
 
S

S. Justin Gengo

Paul,

I think your text box is overwriting itself when the page posts back. If you
are setting a value in the text box when the page is loaded up you need to
do that only the first time the page is loaded.

use:

If Not IsPostBack Then
'---Set you text box here.
End If

This will keep the text box's data from being overwritten on post back.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top