The issue here, as I read it, is whether to store junk into Session, not how
to do session state. Regardless of whether you are using SQL Server or State
Server (or local for that matter), throwing items into session is not
generally the wisest method. For Prefetch, session is really not a good
option, as you are loading up tons of objects you will never use. One could
prefetch into ViewState, but if there are lots of students on a page, you
get a very heavy page. Once again, for information you most likely will not
use (maybe one or two records). With ViewState, you might get away with it
on a fast connection, but there is really no need.
Better to fetch from your persistant data store as needed.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
|
*************************************************
"Mr. Arnold" <MR.
Ar****@Arnold.comwrote in message
news:ek**************@TK2MSFTNGP02.phx.gbl...
>
"DNB" <ii@ii.comwrote in message
news:Oz**************@TK2MSFTNGP04.phx.gbl...
>>I would like to know what you guys think is the best way to access data:
Asp.Net session vs. Database Queries.
In our application we are using asp.net tree view to display hierarchical
data and when user clicks on particular node it brings up totally
different page with all the asp.net controls dynamically generated.
Example:
Tree view Control is as follow:
Student1
Student2
Student3
Student4
......
.....
....
....
Student 75
Now I have 2 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
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.
You can use SQL Server as a state server, which you set that up through
the Web.config, you set up SQL server to be a state server with the .Net
Utility that does configuration. Then you can make a serialized Session
object to hold you session object in session with the data or variables
serialized and saved and retrieved to/from SQL Server. .Net will keep
track and take care of what needs to be done by itself to keep all session
state. All you do is set and get the object.
Look it up use Google and find out how to keep session state using SQL
server as a state server.