Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid - OOP design

Status
Not open for further replies.

SharkTooth

Programmer
Aug 12, 2004
29
US
I created some business objects, for this example a "User" class. User handles everything related to a user, including database transactions (updates, deletes etc.). When I instantiate a new user it goes to the database and loads itself.

Here is my question:

When I load a datagrid I provide the datasource with some kind of collection. I want to utilize my “User” class here so that I can maintain a consistent environment where everything involving user is handled through a “User” object.

What is the right way to handle this? The thought of actually creating a collection of “Users” seems a little extreme. Is that my only option?

Any ideas on the best way to handle this would be appreciated.

Thanks!
 
You need to create some type of collection. It can be a simple array as well. I'm not sure how the datagrid will behave with new records added to an array however. I don't know why creating a collection seems extreme at all.
 
Just seems like a lot of extra work.

1.) I could just load a dataset with the collection of records and bind to the grid.

Or

2.) If I want to stick with the business objects; I'll still have to get the records and iterate through them to build each object (like the user above) and add them to something that derives from ICollection (if I remember correctly). Then I'll have to bind the new collection the the datagrid.

Besides being able to use the business objects, what does this buy me?

Thanks for you thoughts.
 
Use a dataset if you want. I still don't see it being a lot of work, because it's not. Maybe 25 extra lines of code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top