Hi all,
I hope someone can help me with the following problem in ASP.net.
I want to edit the information for a record in a database (MS Access).
On the page I placed several textboxes and dropdownlistboxes. In the
page_load the information from the database is loaded a dataset. With
the following command I place the info from the dataset in the boxes:
txtFirstName.Text = ds.Tables(0).Rows(0).Item("FirstName")
The user can make changes and click a button. In the button click event
a SQL command is created to update the database. The problem is that
when I read the textbox.text value it isn't the value the user entered
but the original value from the dataset (database).
I think it has something to do with the viewstate, but the things I
have tried didn't work. (VIEWSTATE = false for the page and/or boxes)
There is probably another solution possible with the dataset, but
because I'm learning ASP.net I wanted to try this.
Hope someone can help or point me in another direction.
Thanks,
Hans 5 2343
it could be the postback
are u setting this text box like below? without IsPostback check, the
text box will get assigned on every visit to the page.
if (!Page.IsPostback())
{
txtFirstName.Text = ds.Tables(0).Rows(0).Item("Fir*stName")
}
Make sure to wrap a "Not IsPostBack()" around the populating of the
textbox...just to make sure you aren't re-populting it before reading it in.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"ha***********@gmail.com" wrote: Hi all,
I hope someone can help me with the following problem in ASP.net. I want to edit the information for a record in a database (MS Access). On the page I placed several textboxes and dropdownlistboxes. In the page_load the information from the database is loaded a dataset. With the following command I place the info from the dataset in the boxes:
txtFirstName.Text = ds.Tables(0).Rows(0).Item("FirstName")
The user can make changes and click a button. In the button click event a SQL command is created to update the database. The problem is that when I read the textbox.text value it isn't the value the user entered but the original value from the dataset (database).
I think it has something to do with the viewstate, but the things I have tried didn't work. (VIEWSTATE = false for the page and/or boxes)
There is probably another solution possible with the dataset, but because I'm learning ASP.net I wanted to try this.
Hope someone can help or point me in another direction.
Thanks,
Hans
ha***********@gmail.com wrote: Hi all,
I hope someone can help me with the following problem in ASP.net. I want to edit the information for a record in a database (MS Access). On the page I placed several textboxes and dropdownlistboxes. In the page_load the information from the database is loaded a dataset. With the following command I place the info from the dataset in the boxes:
txtFirstName.Text = ds.Tables(0).Rows(0).Item("FirstName")
The user can make changes and click a button. In the button click event a SQL command is created to update the database. The problem is that when I read the textbox.text value it isn't the value the user entered but the original value from the dataset (database).
I think it has something to do with the viewstate, but the things I have tried didn't work. (VIEWSTATE = false for the page and/or boxes)
There is probably another solution possible with the dataset, but because I'm learning ASP.net I wanted to try this.
Hope someone can help or point me in another direction.
Thanks,
Hans
The page_load is executed every time, and before the click handler is executed.
So when the user changes the value and submits, you replace it with the
original value before the click handler tries to save the "new" value.
Solution:
either move the code to PreRender
and/or protect it with a test for "not IsPostBack"
Hans Kesting
Thanks for the fast replies! The IsPostBack check is missing, so ...
I will change and test it tomorrow and post back the result.
Thanks again,
Hans
I works! The IsPostBack check made it work. It's a shame that I didn't
find it myself, because I already used it on another page.
Thanks again to all of you!
Hans This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: tom |
last post by:
Hello,
I have an asp.net web application where I want people
to register themselves.
This takes them through a few pages with prev/next
functionality.
In one of the pages they provide a...
|
by: Paul M. Frazier, Ph.D. |
last post by:
I am writing a user information update page and I populate the form on
Page_Load with the current values of the user's name, etc. When I
change the text in one of the textbox controls (e.g.,...
|
by: Steve S |
last post by:
Heres what I want to do...User types into a texbox, clicks a button, the
button saves that text to a file. The problem is that when I click the
submit button, any changes made to the textbox are...
|
by: JollyK |
last post by:
Hello all,
I have always been having this issue and wondering what the solution is.
When I set the enableviewstate property to false for a textbox, the textbox
always retains its value after a...
|
by: jason |
last post by:
Hello everyone. I am trying to write some custom command events into a
DataGrid. The command that is currently giving me trouble is an "Add"
custom command in the footer of a template column.
...
|
by: Tim |
last post by:
Hi
A while ago I got some help in writing a mock console. The idea was to write a VB app that contained a textbox, then run a process from within the app and redirect the stdout to the textbox. ...
|
by: jason |
last post by:
hello. i am just trying to save a TextBox.Text value to a database, but
strangely, when the value is changed on the web form, the changes are
not recognized in the event where i try to save the...
|
by: d.steininger |
last post by:
Hi there!
Is there a way to bind a Textbox.Text to a ScrollBar.Value (not the
Textbox-own Scrollbar) and vice versa?
The Problem:
I have to deal with two controls. The Textbox should accept...
|
by: lordnaickol |
last post by:
Hi everybody!
I'm trying to develop my first VB.NET application, but I have a big problem.
I have to fill some textboxes with some info comming form a plain text file, but when I assign the...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |