Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session variables converter?

Status
Not open for further replies.

Trebor100

Programmer
Mar 14, 2006
90
GB
Morning all,

I'm in need of some help with something I really should know but for the life of me I can't get to work!!!

I'm trying to pass a list of file uploaders into and out of a session variable. ie:

private List<FileUpload> files;

Session["files"] = List;

List = Session["files"];

Error will be on the List = Session["files"];
I'm thinking i need to use the converter as its not a base class but cannot figure the syntax.

Any help much appricated as I'm googling like a headless chicken on curry night!
 
correction on my quick typing of current state:
private List<FileUpload> files;
Session["files"] = files;
files= Session["files"];
 
It should be something like;
Code:
private List<FileUpload> files;
Session["files"] = files;
files= Session["files"] as List<FileUpload>;
...or;
Code:
private List<FileUpload> files;
Session["files"] = files;
files= (List<FileUpload>)Session["files"];

NB: I have not tried this, just attempting to recall it from memory

Rhys

"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
Terry Pratchett
 
the syntax is correct, but why would you load UI controls in and out of session? that doesn't make sense.
instead, store the required data in session, using a DTO if necessary, and recreate the controls with each request.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top