473,654 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(c ustomerId); }
set { objCustomerDALC .setFistName(va lue, customerId); }

}

CustomerClass.C s

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.execu tereader("blabl abla"); ///Resuming of course
}
public void setName(string name, int id)
{
return sqlhelper.execu tereader("blabl abla"); ///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 1270
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********@ava nsoft.com> wrote in message
news:uu******** ******@TK2MSFTN GP09.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(c ustomerId); }
set { objCustomerDALC .setFistName(va lue, customerId); }

}

CustomerClass.C s

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.execu tereader("blabl abla"); ///Resuming of course
}
public void setName(string name, int id)
{
return sqlhelper.execu tereader("blabl abla"); ///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
2090
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 to the datagrid, but because there isn't a custom object with properties, just a string object, I'm not sure how to reference it in the datagrid. FYI, I can enumerate through the collection... foreach(string modelNum in...
3
1943
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 array) a "BoundColumn" and the 2nd column my button column. The problem is that the BoundColumn wants a DataField name. There is none! So how do I bind this one column to the array column when the array doesn't have column names? And if your...
2
2200
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 properties, ProdID, Description, Quantity and UPC. 3 strings and a long. The LineItemsCollection class inherits from System.Collections.Specialized.NameObjectCollectionBase. It also implements both IEnumerable and IList.
2
1345
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 properties, ProdID, Description, Quantity and UPC. 3 strings and a long. The LineItemsCollection class inherits from System.Collections.Specialized.NameObjectCollectionBase. It also implements both IEnumerable and IList.
0
8379
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.