Session Tuturorial or Walkthrough for a newbie?

G

Guest

I am looking for a good walk through or tutorial on setting up session
managment or some kind of state managment.

This is what I am doing, so maybe you can tell me which direction I should
look at going!

I have a app then once you fill in your query information and sumitt the
form you get my results page. On the results page I have a datagrid that
contains anywhere from 5 to 7000 rows that are shown in a OutLookGroup style.
I am finding that the table the grid builds off is very large to maintain in
viewstate, sometimes 12mb+. What I would like to do is in my grid only keep
what I need to display the grid and my row ID field, but I need to store the
entire table (which is created on the fly based on the query) in state
somehow, then call back to it on post to retrieve my details to further
process the page.

So I guess I need to do the following,
1. create the session (or whatever)
2. process the query and save table to session
3. onclick function retrieve the table from session and do secondary query
4. contrinue to maintain the table in session
5. after timeout dispose/flush table.

Can anyone give me good direction on where I go to make this happen?

Thanks;
 
S

Steven Cheng[MSFT]

Hi Dewright,

AS for the caching table question you mentioned, I think generally the
following code the what we commonly used:

DataSet ds = null;

if(Session["data_key"] == null)
{
QueryDataFromDataBaseAndStoreIntoSession();
}

ds = Session["data_key"] as DataSet;

We can put it in Page_load and bind the grid when necessary(We may adjust
the code according to our actual code logic). Also , for large dataset, of
course we suggest disabling the DataGrid's ViewState and bind grid with
data retrieved from SessionState(or other cache store) in each
request/postback.

Also, how do you think of the ASP.NET's Cache collection? Each ASP.NET
application will has a Cache colleciton assosciated with it, (it's
application scope ), we can store datas in it and add a expire dependency
for it. So for your scenario, you can also consider storeing the large data
records in Cache (with a sessionid associated key if necessary).

Here are some good resources for understanding the SessionState and Cache
in ASP.NET:

#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx

#State Management & Caching
http://msdn.microsoft.com/asp.net/articles/state/default.aspx

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top