473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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/...tml/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.
Nov 19 '05 #1
1 1258
Rocky Lhotka's CSLA Framework is very useful.
http://www.lhotka.net/ArticleIndex.a...ea=CSLA%20.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.
--
Joe Fallon

"Luis Esteban Valencia" <le********@avansoft.com> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
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/...tml/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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pete Nelson | last post by:
Does anyone know of a way to bind a string collection to a datagrid? Basically, I have an object, CreditPlans, and a string collection, ModelNumbers. I'd like to bind the ModelNumbers collection...
3
by: AFN | last post by:
In VB.NET, I can successfully bind a generic datagrid to a 1 dimensional array. But, now I want to add a button column, and so I think I need to make the first column (the one having data in the...
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.