In general, I like to persist data in a database until it is going to be
used. You can prefetch some data, but loading a lot of data into session (or
cache) is not generally the first choice, as most of it will never be used.
In this case, I would NEVER use Session. Caching might be an option,
depending on the nature of the application.
Example: Seventy five students. Prefetch all data about the students and
cache (In this case, better than session). User clicks a single student. You
now have seventy four student's data loaded in session (ie, in memory) for
the length of the session, even though only one was used.
Here is why caching is preferred over session. You cache once across all
sessions, so the same data is available to all people using the particular
page. The cache can be set to update occasionally or, in custom situations,
based on events (very easy if using SQL 2005, 2008 -- requires polling in
2000). If 100 people are using this app at the same time, you have saved 99%
of the memory used to cache over loading in each session.
Here is why caching is not necessarily wise in this case: The more students,
the more information you are caching. And, this is likely to be information
you can just as easily query as needed (caching the query may or may not be
wise, depending on how many times the same person will access the same
record). You can also set cache to expire independently of session timeout.
If the information can be pulled as needed, with perhaps a temporary cache,
I would head this direction.
Now to your options
1) Now when user click on any node (i.e. Node Student2) another page will
be
displayed and all the data related to that will be accesses from SQL
server
using SQL Queries
This can be another page or another control on the same page. GridView and
DetailsView work very nicely together to make the application flow. Throw in
an AJAX UpdatePanel and you can even have the information flow in without a
full server round trip.
2) OR Should all the data be accessed initially loaded into Session
Variable before building Tree View and when user access Node Student 2,
just
get it from Session Variable.
Very rarely do I try to prefetch, much less into session
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
|
*************************************************