Re: DataTable/DataSet in Business Object Class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




An example, using VB2005:

I have a class called Product that has a bunch of properties.

It has a Create method that is used to create new instances
by reading the database for a specific product ID. (It calls
the Data Access layer to get that dataset.) This is in my
Business Layer project.

In my UI project, I have a reference to the business layer
project.

To bind the product class's properties to controls, this is
what you can do:

Open your form. Then click on Data/AddDataSource.

Select <Object>. This will show your projects to which you have
a reference. I drill down into my business layer project and
pick the class I want to bind. It adds it to the Data Sources
window.

You can then drag the property you want bound to, say, a
textbox, over to that textbox and drop it on the textbox,
and it will create a bindingsource for you, and bind that
field to that control.

Even easier: if you have your form opened in design mode,
you can see next to each entry in the DataSources window
that you can select what control you want to use. You can
click on the name of the class (Product in my case) and
drag it over to you form and drop it, and it will create the
labels and the controls for you, and you can then move them
around and change the properties of them.

To do a grid, I set up a ProductList class that has a
generic list of Product instances, and do the same
thing as above, but change the control used for the class
to <DataGridView> before dropping it on the form.

Hope that helps.

Robin S.
--------------------------------------------

<manoj241176@xxxxxxxxx> wrote in message
news:1164734315.510388.203650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am implementing Business object, but while implementing this I
want to have DataTable or DataSet as part of Business Object. For
example, I want to bind controls directly to these Business Objects. So
please suggest me how can I achieve this??

Is is good to create a Property in Business Object which will have
return type as "DataTable / DataSet"?? or what could be the optimum way
to achieve the same.

Thanks & Regards,
Manoj Singh



.



Relevant Pages

  • Re: Business Object and User Interfaces
    ... The business object just create a Client and then it's ... So yes, practically you will have duplicated code, or in other word, two ... different codes that do the same like "Show the client info to the user". ... > to populate your controls' data? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: i love reflection:)
    ... And how does it work when one of the property's of your business object ... load event get a hashtable of all the controls you might want to bind to ... add an event handler that binds to the leave event or similar (1 handler ... write a display method that uses reflection to display all the properies ...
    (microsoft.public.dotnet.languages.vb)
  • Re: UI and BL Interface
    ... I am designing a 3 tier application. ... I have seen examples that the UI creates and new business object ... layers, requiring a communications layer like a web service. ... business objects from its controls' events, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Just uninstalled Delphi 2005 Enterprise
    ... >> Document-View pattern into a UI. ... controls is that they ARE typed. ... TStringGrid and the like that I've seen where data from a business object is ... > practice still have a whole lot of business rules implemented in the UI: ...
    (borland.public.delphi.non-technical)
  • Re: typed datasets vs. business objects
    ... When I use a business object to populate a gridview, for example, I loop through a datareader, populating an array list with instances of a custom class in the middle tier, and then send the array list up to the presentation layer and bind the gridview to it. ...
    (microsoft.public.dotnet.general)