textbox loses values

M

Mark Broadbent

This one has got me absolutely stumped.

At work I have created a simple web form that gets data from a sql backend
and puts this to a dataset.
I have an edit button that when clicked will set the relevant text
properties of several textboxes (to allow for edit)
....all simple so far.
I have a save button that when clicked will then perform the writing back of
the text in the textboxes.
The problem is (and having debugged I see this) that upon entry to the save
button's event handler, the textbox.text properties suddenly become "".
(Before the click handler is entered the values are fine)

These are web controls and SHOULD retain their state.

I've created a very simple form at home a it values are retained on click
....any suggestions are gratefully receieved!

--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
 
K

Karl Seguin

are you rebinding on postback?

if you are rebinding the values are being preserved but you are overwriting
them....

Karl
 
M

Mark Broadbent

Hi Karl. I am not using databinding at all. Im simply copying values to
textboxes on Edit click and copying values from textboxes on Save click
(however on the save click the values have disappeared!).

I know this setup is maybe not the most efficient but it is just a simple
form and I dont want to spend too long on it. (plus I'm dynamically building
up a radiobutton list from the record set so just trying to keep things
simple).

I just cannot see why those values disappear. They are there
pre-click.....and gone the second the click event handler is entered.

--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
 
K

Karl Seguin

Mark,
Thanks for clearing up how your code worked. If I could ask you one
question. Do the textboxes exist when the page is initially loaded, or are
they dynamically added when the edit button is clicked? If they are
dynamically created, than the likeliess problem is that you need to recreate
them when the save button is clicked. If they aren't, then is it possible
that in page_Load you are initializign the textboxes to be blank ?

If I'm wrong on both counts, please provide code.

Karl
 
M

Mark Broadbent

Thanks for your helpful hints. It has lead me to re-think and look at my
page load event again (as you mentioned).
I feel like a bit off an idiot now because I realise I had a bit of code in
there (embedded in a proc) to initialize those textboxes.....and of course
this was getting called on every postback (which I wanted with exception of
those clear statements. I've refactored the code now so it all works like I
would expect.

Thanks for your help I needed that nudge in the right direction (even though
I initially thought 'no of course I'm not doing that!')

Br,

Mark.
 

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

Top