DataTable/DataSet in Business Object Class

M

manoj241176

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
 
R

RobinS

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.
 

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

Top