Re: Global datasets
- From: David Colliver <DavidColliver@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 14 Nov 2006 06:11:01 -0800
Hi,
No, I am not thinking of cache or session. That is not what I want.
I want to create a dataset at the start of the page process. During the
page, I want to use that dataset in many places. The dataset I refer to is
actually a menu system built from the database.
examples of use...
1. Creating a breadcrumb trail.
2. Building the main navigation.
3. Building the sub navigation.
4. Knowing where I am so that objects on the page resond accordingly.
What I don't want (in the above scenario) is to create the dataset 4 times.
I want to use it in 4 places. This can be in the page itself, in can be in
the breadcrumb usercontrol, it can be in the main navigation user control.
There is no point in contacting the database 4 times for exactly the same
data. This is expensive and time consuming. So, I want to create it only once
at "global level" for the page and various page objects use it.
I don't need to cache it (yet anyway). At the moment, I am happy to create
it for every call to the page, but only once in the life of the call to the
page.
How do I do that?
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Dan Bass" wrote:
David,.
From what I can tell, you're confusing "Global" with "Cached" or "Session"
objects... Are you trying to building a dataset object once, then have
subsequent page refreshes use the cached object?
I punched "ASP.Net session objects" into google and got this link straight
away which goes into the details a bit more...
http://www.aspfree.com/c/a/ASP.NET/Application-and-Session-Objects-in-ASP.NET/
If this is not what you want to do, or you want more help on it, let me
know.
Thanks.
Dan.
"David Colliver" <DavidColliver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:61FEC230-CF39-4F9D-AFD5-3985F9E1E573@xxxxxxxxxxxxxxxx
Hi,
using c#, 1.1
I know that we are not supposed to use global variables etc. in c#
I am having a problem, but not sure how to resolve. I did have another
post
here, but may have over confused things, so I will start afresh.
An example of what I want to do...
namespace MyDataSet
{
public class MyDSClass
{
public DataSet MyDS
{
// Do the dataset stuff.
return MyData;
}
}
}
I want to be able to instantiate the above code only once per page load
and
return a dataset.
in my page...
using MyDataSet;
namespace MyPage
{
public class MyPageClass : System.Web.UI.Page
{
private void Page_Load(object sender, eventargs e)
{
// I need to open the dataset created in the MyDSClass, without
re-instantiating it. If it needs to re-instantiate, then only do it once.
MyDataGrid.DataSource = MyDS;
MyDataGrid.DataBind();
}
}
}
So, the above code wants to use the dataset, but not have to create it. If
it has to be created, then I need to do it, but then other controls that
use
it should not have to re-create it once it has re-created.
using MyDataSet;
namespace MyUC
{
public class MyPageClass : System.Web.UI.UserControl
{
private void Page_Load(object sender, eventargs e)
{
// I need to open the dataset created in the MyDSClass, without
re-instantiating it. If it needs to re-instantiate, then only do it once.
MyUCDataGrid.DataSource = MyDS;
MyUCDataGrid.DataBind();
}
}
}
What I am trying to avoid is to have to go to the database each time MyDS
is
needed. When the page is run, I only want to have to go to the database
once,
to build my dataset. I want to be able to use that dataset in the page, or
control that the page hosts.
How can I make my dataset "global" and how do I then view the "global"
dataset in each control without creating a new dataset each time it is
required?
All help is appreciated. Please do ask me questions if needed so that I
can
get this resolved.
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
- Follow-Ups:
- Re: Global datasets
- From: Dan Bass
- Re: Global datasets
- References:
- Global datasets
- From: David Colliver
- Re: Global datasets
- From: Dan Bass
- Global datasets
- Prev by Date: How to load page in browser
- Next by Date: Re: ASP.NET SMTP mail never received
- Previous by thread: Re: Global datasets
- Next by thread: Re: Global datasets
- Index(es):
Relevant Pages
|