Everybody Read this and participate. How to bind custom object collection to a datagrid.?

  • Thread starter Luis Esteban Valencia
  • Start date
L

Luis Esteban Valencia

Please everybody participate in this question.

Hello my applicacion has many layers and classes and I think its well
structured. PLease let me know if you disagree and why.
1. I have the user Interface (webforms)
2. I have a class Called Customer Class (it only has private fields,
properties). Those properties connecto a Class called
CustomerDALC (Customer Data Access Logic Component). this one must be the
only responsible to access data. the acess of the data must be transparent
to the customerclass.
3. This last class is the one that actually retrieves or sets the
information from the database.

So here is the code.

public class Customer
{
// Private fields, to hold the state of the Product entity
private int customerId;
private string firstname;
private string lastname;

CustomerDALC objcustomerDalc;

// Public properties, to expose the state of the entity
public int getName
{
get { return objcustomerDalc.getFirstName(customerId); }
set { objCustomerDALC.setFistName(value, customerId); }

}

CustomerClass.Cs

public class CustomerDALC
{
private string conn_string;

public CustomerDALC()
{
// Acquire the connection string from a secure or encrypted location
// and assign to conn_string
}
public int getName(int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
public void setName(string name, int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
}


Suppose that in my webform I want to retrieve all the customers and bind to
a datagrid? what is the best way to do it?
Create an array of CustomerObjects? or create a dataset? where would I put
that dataset.




I took the code from this page
http://msdn.microsoft.com/practices/ArchDes/default.aspx?pull=/library/en-us/dnbda/html/boagag.asp

If you have other techniques to program with layers and objects and passing
info between layers please let me know. I am trying to modelate a generic
way to make this but I havent done it before.
 
J

Joe Fallon

Rocky Lhotka's CSLA Framework is very useful.
http://www.lhotka.net/ArticleIndex.aspx?area=CSLA .NET

I use it to create custom Business Objects including Editable collections of
Customer objects and more lightweight Read Only Collections of CustomerInfo
objects. I use the ROCs to bind to grids.

You can choose to keep the ROC in session for postbacks (and remove it when
you leav the page)
or hit the DB each time to retireve it. Depends on your needs.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top