Re: Global datasets




Sticking with the first method again. The answer is no. The dataset class
doesn't care who references it. All it knows is that it contains the data in
its own object instance. It's up to the (typically) Page_Load event method
to then decide what controls exist that need this instance, and then assign
the data set to it.


The algorithm for Page_Load would look something like this:

Create my DataSet
Populate my DataSet from the Database

Create my CrumbTrail Object
Assign the Dataset to the CumbTrail Object (something like
CrumbTrailObj.DataSetProperty)
Do some CrumbTrail "stuff"

Create another control object instance
assign the dataset to this object
Do some processing on this object

etc...



"David Colliver" <DavidColliver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E35D9415-23F0-4B87-88DE-77E90F83DB3E@xxxxxxxxxxxxxxxx
Hi Dan,

Thanks for sticking with me on this... your assumption is correct. I just
want to create the dataset once (as it is a database process, hence
process
expensive) and be able to use it any time I choose, wether in a page or
control.

For the first method, doesn't that assume that the original dataset class
needs to know what classes will want to use it? The way I am visualising
this
is that the dataset pushes its data into the page or user controls... I
need
to have the dataset not know what wants to use it, just that it is there
for
anything/anybody to use.

I have never (knowingly) written a singleton, so I don't know anything
about
these. Can you give me a quick example of how I would write one and how I
would call it from within my pages/controls?

Thank you for the help so far...

Regards,
Dave Colliver.
http://www.MatlockFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available


"Dan Bass" wrote:

David,

Then I assume that what you mean by global is that during the page
loading
sequence, you have different objects that all need the same dataset?

If this is the case, then either create the dataset, and pass it into
what
ever objects require it (either setting up a property on that class, or
passing it in as a method parameter), or, create a static instance
(something like a singleton object I suppose) so that each time you need
to
reference the dataset, you're getting the same "global" instance.

The first method of doing things is far better... Since everything you've
described is intrinsic to having a datasource, then it makes sense to
have a
DataSet property on each class, so that you, as I've said, first create
the
dataset you need, calling the database and retrieving the data, then
creating each object and assigning this instance of your dataset to the
property so that each object then can use it in turn...

Doesthis make more sense? If not, keeping asking away!
Thanks.
Dan.

"David Colliver" <DavidColliver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:E60BE6FF-9E2B-4CEE-A725-4E22417DB366@xxxxxxxxxxxxxxxx
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








.



Relevant Pages

  • Re: Global datasets
    ... want to create the dataset once (as it is a database process, ... the breadcrumb usercontrol, it can be in the main navigation user control. ... public class MyPageClass: System.Web.UI.Page ... re-instantiating it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Global datasets
    ... Right, I understand that, but that means that all my pages control the ... Sticking with the first method again. ... Populate my DataSet from the Database ... re-instantiating it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: instant Lisp web application publishing
    ... flow of control (e,g. first log in the user, then show page x, than ... of Lisp if they want) ... flexible database that can be easily mapped into OOP terminology (so you ... Also I don't have a good candidate server to deploy it too. ...
    (comp.lang.lisp)
  • Re: Communication Log
    ... May I send you copy of the database that I made? ... a communication log in the database so that it will store the Date, ... ContactMethodID ... The above controls are set up in a page using te tab control. ...
    (microsoft.public.access.tablesdbdesign)
  • RE: 438 - Object doesnt support this property or method
    ... I created a new database and imported everything from the original. ... Missing is the Reference to the EzFTP control. ... Set con = Application.CurrentProject.Connection ...
    (microsoft.public.access.formscoding)