ASP.NET Session Data/Array?

Hello,

How would I achieve this:

"SELECT Names from SomeTable" populates a 1-d array called CustomerNames

That array remains even though the user changes pages etc... Its pretty much a constant (as to put it) I need this list accessible from all over the app. I just want to minimize on SQL calls.

Is this possible? I dont want to have to run that SQL statement every time I need the list (elsewhere int eh app) I jsut want it to run once and be publically available
LVL 7
pegasysAsked:
Who is Participating?
 
Bob LearnedCommented:
Store any variable in a session variable:

VB.NET

Set variable:
   Session("CustomerNames") = CustomerNames;

Get variable:
   CustomerNames = Session("CustomerNames")

Bob
0
 
pegasysAuthor Commented:
are sessionvariables datatype-less or do they assume the data-type of the content?
0
 
Bob LearnedCommented:
Session variables are type=object, and can accept anything, so you need to cast the return type into a specific variable type to access its properties.

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.