ASP.NET Session Data/Array?

Posted on 2007-08-10
Last Modified: 2013-11-07

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
Question by:pegasys
    LVL 96

    Accepted Solution

    Store any variable in a session variable:


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

    Get variable:
       CustomerNames = Session("CustomerNames")

    LVL 7

    Author Comment

    are sessionvariables datatype-less or do they assume the data-type of the content?
    LVL 96

    Expert Comment

    by:Bob Learned
    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.


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Schema Not Showing in SSDT Database Project 26 37
    Query datatable in LINQ 6 27
    Aspnet xml 2 27
    Jquery oncheck to update SPAN 31 33
    Normally a window is moved by clicking on the caption bar and dragging. You may want your user to be able to move borderless forms or move a form by clicking anywhere in the form without the limitation to the caption bar. There are many ways to do i…
    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now