473,549 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to access session state from a class module

I have an ASP .Net 2.0 site that I am working on. It has a master page and
a content page. I also created a separate class module that returns a
DataSet to feed my GridView. So far, so good.

The thing is that the method that returns the DataSet is computationally
expensive and I really need to create the whole DataSet only once per
session. Once it's created, I'd like to return the same DataSet to the
GridView for operations such as sorting the columns, etc.

So I figured that the best way to do this is to persist the DataSet in the
Session state. My question is, how do I access the Session object from
class module. intellisense does not show an Application or Session object.

--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions
Nov 19 '06 #1
6 1913
HttpContext.Cur rent.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua******** *****@TK2MSFTNG P03.phx.gbl...
>I have an ASP .Net 2.0 site that I am working on. It has a master page and
a content page. I also created a separate class module that returns a
DataSet to feed my GridView. So far, so good.

The thing is that the method that returns the DataSet is computationally
expensive and I really need to create the whole DataSet only once per
session. Once it's created, I'd like to return the same DataSet to the
GridView for operations such as sorting the columns, etc.

So I figured that the best way to do this is to persist the DataSet in the
Session state. My question is, how do I access the Session object from
class module. intellisense does not show an Application or Session
object.

--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions

Nov 19 '06 #2
Yep!

That did the trick! Thank you.

Now that we have that one solved, how about filtering the DataSet that the
GridView is tied to, WITHOUT re-reading all the data?

By the way, any relation to R. Shmuel Goldin in Englewood, NJ?

Yossi
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O5******** ******@TK2MSFTN GP03.phx.gbl...
HttpContext.Cur rent.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua******** *****@TK2MSFTNG P03.phx.gbl...
>>I have an ASP .Net 2.0 site that I am working on. It has a master page
and a content page. I also created a separate class module that returns a
DataSet to feed my GridView. So far, so good.

The thing is that the method that returns the DataSet is computationally
expensive and I really need to create the whole DataSet only once per
session. Once it's created, I'd like to return the same DataSet to the
GridView for operations such as sorting the columns, etc.

So I figured that the best way to do this is to persist the DataSet in
the Session state. My question is, how do I access the Session object
from class module. intellisense does not show an Application or Session
object.

--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions


Nov 20 '06 #3
If I understood you correctly, you have a fully-populated dataset and you
would like to filter the data for databinding to a gridview. There are two
standard ways of doing this:

1. Creating a DataView for the datatable in your dataset and databinding the
gridview to the dataview.

2. Creating an array of the records you want to show with DataTable.Selec t()
method and databinding the gridview to the array.

In both way you will need to specify your filtering conditions in the format
similar to regular sql 'where' syntax. Read in MSDN about these 2 methods
and don't hesitate to ask more questions.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
Yep!

That did the trick! Thank you.

Now that we have that one solved, how about filtering the DataSet that the
GridView is tied to, WITHOUT re-reading all the data?

By the way, any relation to R. Shmuel Goldin in Englewood, NJ?

Yossi
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O5******** ******@TK2MSFTN GP03.phx.gbl...
>HttpContext.Cu rrent.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua******* ******@TK2MSFTN GP03.phx.gbl...
>>>I have an ASP .Net 2.0 site that I am working on. It has a master page
and a content page. I also created a separate class module that returns
a DataSet to feed my GridView. So far, so good.

The thing is that the method that returns the DataSet is computationally
expensive and I really need to create the whole DataSet only once per
session. Once it's created, I'd like to return the same DataSet to the
GridView for operations such as sorting the columns, etc.

So I figured that the best way to do this is to persist the DataSet in
the Session state. My question is, how do I access the Session object
from class module. intellisense does not show an Application or Session
object.

--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions



Nov 20 '06 #4
Eliyahu,

Thank you. I'll give that a try.

In the meantime, I have another question, this time relating to the
GridView. I defined 2 of the columns to be ButtonFields. The caption of
the button is set by the value of the corresponding field in the dataset.
When someone clicks on the button, how do I determine what is the caption of
the button, WITHOUT having to go back to the DataSet?

I do have a CommandRow method defined but for some reason, when I try to get
the text of a cell in the GridView, if the cell is a button I always get
back an empty string......

Yossi

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:Og******** ******@TK2MSFTN GP02.phx.gbl...
If I understood you correctly, you have a fully-populated dataset and you
would like to filter the data for databinding to a gridview. There are two
standard ways of doing this:

1. Creating a DataView for the datatable in your dataset and databinding
the gridview to the dataview.

2. Creating an array of the records you want to show with
DataTable.Selec t() method and databinding the gridview to the array.

In both way you will need to specify your filtering conditions in the
format similar to regular sql 'where' syntax. Read in MSDN about these 2
methods and don't hesitate to ask more questions.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
>Yep!

That did the trick! Thank you.

Now that we have that one solved, how about filtering the DataSet that
the GridView is tied to, WITHOUT re-reading all the data?

By the way, any relation to R. Shmuel Goldin in Englewood, NJ?

Yossi
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O5******** ******@TK2MSFTN GP03.phx.gbl...
>>HttpContext.C urrent.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua****** *******@TK2MSFT NGP03.phx.gbl.. .
I have an ASP .Net 2.0 site that I am working on. It has a master page
and a content page. I also created a separate class module that returns
a DataSet to feed my GridView. So far, so good.

The thing is that the method that returns the DataSet is
computationa lly expensive and I really need to create the whole DataSet
only once per session. Once it's created, I'd like to return the same
DataSet to the GridView for operations such as sorting the columns,
etc.

So I figured that the best way to do this is to persist the DataSet in
the Session state. My question is, how do I access the Session object
from class module. intellisense does not show an Application or
Session object.

--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions



Nov 20 '06 #5
Yossi,

I don't have any practical experience with ButtonFields but I guess if a
cell contains a button, you would need to look at the cell's Controls
collection to get the button object first and then get the text from the
button rather than from the cell.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Yossi" <jo**********@f irstfi.comwrote in message
news:eF******** *****@TK2MSFTNG P02.phx.gbl...
Eliyahu,

Thank you. I'll give that a try.

In the meantime, I have another question, this time relating to the
GridView. I defined 2 of the columns to be ButtonFields. The caption of
the button is set by the value of the corresponding field in the dataset.
When someone clicks on the button, how do I determine what is the caption
of the button, WITHOUT having to go back to the DataSet?

I do have a CommandRow method defined but for some reason, when I try to
get the text of a cell in the GridView, if the cell is a button I always
get back an empty string......

Yossi

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:Og******** ******@TK2MSFTN GP02.phx.gbl...
>If I understood you correctly, you have a fully-populated dataset and you
would like to filter the data for databinding to a gridview. There are
two standard ways of doing this:

1. Creating a DataView for the datatable in your dataset and databinding
the gridview to the dataview.

2. Creating an array of the records you want to show with
DataTable.Sele ct() method and databinding the gridview to the array.

In both way you will need to specify your filtering conditions in the
format similar to regular sql 'where' syntax. Read in MSDN about these 2
methods and don't hesitate to ask more questions.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:uA******* *******@TK2MSFT NGP02.phx.gbl.. .
>>Yep!

That did the trick! Thank you.

Now that we have that one solved, how about filtering the DataSet that
the GridView is tied to, WITHOUT re-reading all the data?

By the way, any relation to R. Shmuel Goldin in Englewood, NJ?

Yossi
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O5******** ******@TK2MSFTN GP03.phx.gbl...
HttpContext. Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua***** ********@TK2MSF TNGP03.phx.gbl. ..
>I have an ASP .Net 2.0 site that I am working on. It has a master page
>and a content page. I also created a separate class module that
>returns a DataSet to feed my GridView. So far, so good.
>
The thing is that the method that returns the DataSet is
computation ally expensive and I really need to create the whole
DataSet only once per session. Once it's created, I'd like to return
the same DataSet to the GridView for operations such as sorting the
columns, etc.
>
So I figured that the best way to do this is to persist the DataSet in
the Session state. My question is, how do I access the Session object
from class module. intellisense does not show an Application or
Session object.
>
--
-------------------------------
Joseph I. Ceasar
CLS Computer Solutions
>




Nov 20 '06 #6
I found the answer:

((IButtonContro l)(myGridView.S electedRow.Cell s[0].Controls[0])).Text;

This will get the first button in the first cell.
Thank you.
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O4******** ******@TK2MSFTN GP04.phx.gbl...
Yossi,

I don't have any practical experience with ButtonFields but I guess if a
cell contains a button, you would need to look at the cell's Controls
collection to get the button object first and then get the text from the
button rather than from the cell.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Yossi" <jo**********@f irstfi.comwrote in message
news:eF******** *****@TK2MSFTNG P02.phx.gbl...
>Eliyahu,

Thank you. I'll give that a try.

In the meantime, I have another question, this time relating to the
GridView. I defined 2 of the columns to be ButtonFields. The caption of
the button is set by the value of the corresponding field in the dataset.
When someone clicks on the button, how do I determine what is the caption
of the button, WITHOUT having to go back to the DataSet?

I do have a CommandRow method defined but for some reason, when I try to
get the text of a cell in the GridView, if the cell is a button I always
get back an empty string......

Yossi

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:Og******** ******@TK2MSFTN GP02.phx.gbl...
>>If I understood you correctly, you have a fully-populated dataset and
you would like to filter the data for databinding to a gridview. There
are two standard ways of doing this:

1. Creating a DataView for the datatable in your dataset and databinding
the gridview to the dataview.

2. Creating an array of the records you want to show with
DataTable.Sel ect() method and databinding the gridview to the array.

In both way you will need to specify your filtering conditions in the
format similar to regular sql 'where' syntax. Read in MSDN about these 2
methods and don't hesitate to ask more questions.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:uA****** ********@TK2MSF TNGP02.phx.gbl. ..
Yep!

That did the trick! Thank you.

Now that we have that one solved, how about filtering the DataSet that
the GridView is tied to, WITHOUT re-reading all the data?

By the way, any relation to R. Shmuel Goldin in Englewood, NJ?

Yossi
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O5******** ******@TK2MSFTN GP03.phx.gbl...
HttpContext .Current.Sessio n
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
>
"Joseph I. Ceasar" <ji*@pipeline.c omwrote in message
news:ua**** *********@TK2MS FTNGP03.phx.gbl ...
>>I have an ASP .Net 2.0 site that I am working on. It has a master
>>page and a content page. I also created a separate class module that
>>returns a DataSet to feed my GridView. So far, so good.
>>
>The thing is that the method that returns the DataSet is
>computatio nally expensive and I really need to create the whole
>DataSet only once per session. Once it's created, I'd like to return
>the same DataSet to the GridView for operations such as sorting the
>columns, etc.
>>
>So I figured that the best way to do this is to persist the DataSet
>in the Session state. My question is, how do I access the Session
>object from class module. intellisense does not show an Application
>or Session object.
>>
>--
>-------------------------------
>Joseph I. Ceasar
>CLS Computer Solutions
>>
>
>




Nov 20 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4721
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
0
1315
by: Michael O'Brien | last post by:
I'm trying to hook in a specialized state store server into ASP.NET. I understand I can create a HttpModule and hook the events OnAcquireState and OnReleaseState. So far so good. But, it seems that the framework owns the HttpSessionState instance (HttpContext.Session) and so my state store module must use the Add, Remove and Clear methods...
3
1577
by: Wee Bubba | last post by:
i have a seperate class which i want to access the session state from. as a workaround i am able to access the session state by inheriting from the Page class. but this seems a waste as I dont need any other Page features. i.e. public class Stopwatch : Page //inherit from Page class to get access to session object { ... }
4
3903
by: Danny W | last post by:
Hi There! Is it possible to use HttpModule to replace the built-in ASP.NET Session object? I want to write a HttpModule that will handle storing and retrieving of session values from an external database. For example, when a page set values to Session object such as Session("somevar")=1 then I want my HttpModule to get notified and store...
14
4813
by: Lauri Kotilainen | last post by:
Hi, I've already tried several avenues for this, and am quite stumped. The issue I'm facing is a weird case of sessions getting mixed up (ie. users seeing each others' data). Apparently this happens at peak load times. The configuration is W2K3 with ASP.NET 1.1, IIS6.0, Cookieless sessions and SQL Server as a Session State backend. The...
9
5296
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls...
2
2427
by: Daflookie | last post by:
For one reason or another I am unable to access Session contents in my asp.net application via the global.asax's Application_Error event. I can pull this exact code snippet below out of global.asax and place it in a normal page (or class file that doesn't inherit from system.web.ui.page) and things work fine: Sub Application_Error(ByVal...
3
3607
by: SevDer | last post by:
Hi All, I am recently experiencing a weird problem. I don't know what exactly is the cause of the problem but here is my scenario and symptoms. First of all here is my architecture 1. I have a main framework (DNN) build in VB.NET which I try to prevent changing things there (simply not changing it) 2. I have a virtual directory under...
4
2507
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) Any reason why even though I did this I keep getting this error.... Server Error in '/abc' Application.
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.