dataset disappears on postback

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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?
 
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?
 
Back
Top