Bind Complex Custom Business Object to DataGrid

Discussion in 'ASP .Net Datagrid Control' started by Stuart Whiteford, Jan 14, 2004.

  1. Guys,

    Still fairly new to ASP.NET. I want to bind a collection of (what I
    think are) fairly complex Business Objects to a DataGrid.

    The properties of the Object (called Company) look something like this
    (I have a separate class for Address):

    Company.ID
    Company.Title
    Company.Address.Street
    Company.Address.Town
    Company.Address.PostCode
    Company.TelNo

    If I bind a collection of Companies to the DataGrid I can access the
    properties directly associated with Company (ID, Title, TelNo) but I
    can't figure out how to get the properties of the Company's Address.

    Any thoughts?

    TIA,
    Stuart.
     
    Stuart Whiteford, Jan 14, 2004
    #1
    1. Advertising

  2. Stuart Whiteford

    Michael Guest

    You can assign any object as a datasource for a datagrid as long as you
    implement the IEnumerable interface. You should do this on your Company
    object. To do that you write code for the function getEnumerator(), which
    returns an Ienumerator, that will describe your data. Lots of information
    out there on that, but this should get you started.

    http://msdn.microsoft.com/library/d...ectionsienumerableclassgetenumeratortopic.asp

    --Michael

    "Stuart Whiteford" <> wrote in message
    news:...
    > Guys,
    >
    > Still fairly new to ASP.NET. I want to bind a collection of (what I
    > think are) fairly complex Business Objects to a DataGrid.
    >
    > The properties of the Object (called Company) look something like this
    > (I have a separate class for Address):
    >
    > Company.ID
    > Company.Title
    > Company.Address.Street
    > Company.Address.Town
    > Company.Address.PostCode
    > Company.TelNo
    >
    > If I bind a collection of Companies to the DataGrid I can access the
    > properties directly associated with Company (ID, Title, TelNo) but I
    > can't figure out how to get the properties of the Company's Address.
    >
    > Any thoughts?
    >
    > TIA,
    > Stuart.
     
    Michael, Jan 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anatoly
    Replies:
    0
    Views:
    373
    Anatoly
    Oct 22, 2003
  2. =?Utf-8?B?S2h1emVtYQ==?=

    Object Data Source and Custom Business Object

    =?Utf-8?B?S2h1emVtYQ==?=, Jun 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    786
    =?Utf-8?B?S2h1emVtYQ==?=
    Jun 27, 2005
  3. Luis Esteban Valencia
    Replies:
    1
    Views:
    650
    Joe Fallon
    Jul 3, 2005
  4. Larry R

    Bind CheckBoxList to Business Object

    Larry R, May 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    504
    Larry R
    May 20, 2006
  5. Dan Caron
    Replies:
    1
    Views:
    188
Loading...

Share This Page