Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instantiating and using two instances of the same BO
Message
De
15/07/2009 17:06:07
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
15/07/2009 15:13:07
Tegron Tegron
Platinum Technologies
Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01412544
Message ID:
01412579
Vues:
46
Hi Tegron,

Linda gave you a solution as well, but I thought I would add a couple of thoughts.

There are some variables to consider here with regard to how you are using this data and if you intend to update it. Since you are working with a web application, the business object is not going to have this data still on a postback. You can retrieve your data in a dataset and then save that to the session if that is appropriate. Then on a postback you can retrieve that DataSet and set it as the current DataSet on the business object again for other operations.
DataSet dsGuardian1;
DataSet dsGuardian2;
this.oRequest.GetRequestsByGuardianID(this.guardianID, 1);
dsGuardian1 = this.oRequest.DataSet;
dsGuardian2 = this.oRequest.DataSet;
There are lots of ways to do this but they are all going to include using a single business object and either retrieving data in seperate datasets, seperate EntityLists, and then since it is web and if you need to work with it after a postback, saving the data and setting it back on the business object like this.
this.oRequest.SetCurrentDataSet(dsGuardian2);
If this isn't enough to get you going, I have other examples of my own I can provide you with where I retrieve different data on the same page from the same business object and bind them to different controls.
Tim

>Is there a way to instantiate a business object twice and use it with different values? I would appreciate any recommendations somone can offer.
>
>I have two tabs on a webform that contain two different grid items. I have created two different form-level variables and I retrieve data into these two business objects:
>
>e.g. this.IRequests & MCARequests
>
>The problem is I can only bind to one.
>
>They're instantiate like the following:
>
> this.IRequest = (Request)this.RegisterBizObj(new Request());
> this.MCARequest = (Request)this.RegisterBizObj(new Request());
>
>I fill them like this:
>
> this.IRequest.GetRequestsByGuardianID(this.guardianID, 1);
> this.MCARequest.GetRequestsByGuardianID(this.guardianID, 2);
>
>When I bind it only shows one business object available. Is there a way to display two different business objects that have different names, so tha tI can bind each grid to them. Currently they are both displaying the same data in both grids. If I can instantiate the same business object with a different name and register the two names with the form, I think that this would solve my problem.
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform