Updating dataset with values from TextBox control

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
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
 
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
 
Back
Top