dataset disappears on postback

G

Guest

i have a dataset object i put on my webform, i fill the dataset, bind it to my grid. the grid displays with my data. i put a button with no code in it, but just to have it force a postback. every time this happens, my dataset is set to nothing

for the fun of it, i created 2 datasets and left one of them 'untouched', meaning it wasn't bound to anything... just filled with data. sure enough, it reset to "nothing" on a postback. this is causing all kinds of problems for me and i have no idea why. there is no good reason for it to happen... nowhere in code is it reset

any ideas?
 
E

Eliyahu Goldin

The server doesn't keep a webform running all the time. It loads the worm
upon client request, runs it and then unloads. The next client causes the
form to get loaded again. The form doesn't remember anything about the
previous run unless you take special care about it. On every postback you
have to populate your dataset again and to re-bind to the grid.

Eliyahu

jhill said:
i have a dataset object i put on my webform, i fill the dataset, bind it
to my grid. the grid displays with my data. i put a button with no code in
it, but just to have it force a postback. every time this happens, my
dataset is set to nothing.
for the fun of it, i created 2 datasets and left one of them 'untouched',
meaning it wasn't bound to anything... just filled with data. sure enough,
it reset to "nothing" on a postback. this is causing all kinds of problems
for me and i have no idea why. there is no good reason for it to happen...
nowhere in code is it reset.
 
G

Guest

oh my... this is scary. every time a person clicks any button or does any interaction, i need to reload all of the data. that's going to be incredibly inefficient. is there a way to store the dataset in a session variable or something like that? i really only need it for the existing page, so is there any way to make some kind of global variable or page variable that will maintain for the current session, while on that current page

i've read that storing datasets as a session variable may not work for some reason?
 
V

Valerian John

You could hang on to the dataset by storing it in a ViewState or Session
State object (both have +s & -s).


jhill said:
oh my... this is scary. every time a person clicks any button or does any
interaction, i need to reload all of the data. that's going to be
incredibly inefficient. is there a way to store the dataset in a session
variable or something like that? i really only need it for the existing
page, so is there any way to make some kind of global variable or page
variable that will maintain for the current session, while on that current
page?
i've read that storing datasets as a session variable may not work for
some reason?
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top