Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Everybody Read this and participate. How to bind custom object collection to a datagrid.?

Reply
Thread Tools

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

 
 
Luis Esteban Valencia
Guest
Posts: n/a
 
      07-01-2005
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.


 
Reply With Quote
 
 
 
 
Joe Fallon
Guest
Posts: n/a
 
      07-03-2005
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" <> wrote in message
news:uu$...
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Bind GridView to generic custom object List collection Steven Baggs ASP .Net 5 10-18-2005 09:45 PM
Cant bind Repeater to Custom Collection A Traveler ASP .Net Web Controls 2 10-19-2004 03:24 PM
Cant bind Repeater to Custom Collection A Traveler ASP .Net 2 10-19-2004 03:24 PM
!!! URGENT: This concerns everybody, please read inside !!! Un-partisan Moderate Computer Support 13 11-19-2003 11:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57