How to access session state from a class module

J

Joseph I. Ceasar

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.
 
J

Joseph I. Ceasar

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 said:
HttpContext.Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Joseph I. Ceasar said:
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.
 
E

Eliyahu Goldin

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.Select()
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 said:
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 said:
HttpContext.Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Joseph I. Ceasar said:
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.
 
Y

Yossi

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 said:
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.Select() 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 said:
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 said:
HttpContext.Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


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.
 
E

Eliyahu Goldin

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 said:
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 said:
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.Select() 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 said:
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


message HttpContext.Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


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.
 
Y

Yossi

I found the answer:

((IButtonControl)(myGridView.SelectedRow.Cells[0].Controls[0])).Text;

This will get the first button in the first cell.


Thank you.


Eliyahu Goldin said:
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 said:
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 said:
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.Select() 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]


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


message HttpContext.Current.Session

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


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.
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top