Session State Index

J

Jim McGivney

Session state is a collection.
Is it possible to either add or retrieve a value from Session State by
specifying an index number in place of a key ?

If the Session State is initialized with:
Session.add["Pram1"] = Value1;
Session.add["Pram2"] = Value2;

Can they be accessed with ?
myVar1 = Session[0];
myVar2 = Session[1];

Is this even the proper syntax ?

I could not find any documentation on this. If it exists, where is it in
the documentation ?

Thanks in advance for your help,
Jim
 
G

Guest

yes.. Session[0] is valid..

When you type Session[ in Visual Studio, the intellisense itself is showing
this as one of the 2 possible syntaxes ..

For documentaion, MSDN should have some..
 
S

Siva M

Yes, it is possible. Use square brackets ([]) for C# and regular brackets ()
for VB.NET.

Here is the MSDN documentation:
http://msdn.microsoft.com/library/d...essionstatehttpsessionstateclassitemtopic.asp


Session state is a collection.
Is it possible to either add or retrieve a value from Session State by
specifying an index number in place of a key ?

If the Session State is initialized with:
Session.add["Pram1"] = Value1;
Session.add["Pram2"] = Value2;

Can they be accessed with ?
myVar1 = Session[0];
myVar2 = Session[1];

Is this even the proper syntax ?

I could not find any documentation on this. If it exists, where is it in
the documentation ?

Thanks in advance for your help,
Jim
 
B

Bruce Barker

if you look at the documentation, you will that Page.Session returns a
HttpSessionState. if you look at the Item property of HttpSessionState, you
will see it supports string and integer indexing.

to look this up in docmentation, in the index i typed Page Class. then i
picked all members. then i picked Session. then i picked Item to get the
answer.

-- bruce (sqlwork.com)
 

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