databinding & classes

Discussion in 'ASP .Net Datagrid Control' started by Bart, Oct 26, 2004.

  1. Bart

    Bart Guest

    I made an arraylist wich contains a certain amount of objects from the class
    'employees'. The class 'employees' contains also an object 'department'. You
    can see the class diagram (http://users.pandora.be/bart.geurs/class.gif).

    The next step is to bind that arraylist to a datagrid. It works, but I only
    see the data from the 'root'-object employee. I cannot get the data from the
    department-object into that datagrid.

    Code :
    dim list as new arraylist
    list=fillList() --> sub wich handles the filling of the arraylist

    datagrid1.datasource=list
    datagrid1.databind()

    How can I get the data from the 'sub-object' into the datagrid ? Or maybe
    I'm wrong with using an arraylist ?
     
    Bart, Oct 26, 2004
    #1
    1. Advertising

  2. Bart

    Flare Guest


    >I made an arraylist wich contains a certain amount of objects from the
    >class
    > 'employees'. The class 'employees' contains also an object 'department'.
    > You
    > can see the class diagram (http://users.pandora.be/bart.geurs/class.gif).
    >
    > The next step is to bind that arraylist to a datagrid. It works, but I
    > only
    > see the data from the 'root'-object employee. I cannot get the data from
    > the
    > department-object into that datagrid.
    >
    > Code :
    > dim list as new arraylist
    > list=fillList() --> sub wich handles the filling of the arraylist
    >
    > datagrid1.datasource=list
    > datagrid1.databind()
    >
    > How can I get the data from the 'sub-object' into the datagrid ? Or maybe
    > I'm wrong with using an arraylist ?


    ArrayList is fine. But think about what you are trying to do. How would you
    want your nested object to show? The "right" way is to show a treelike
    structure where all root objects (employee) was shown and a + sign was shown
    so you could "out-fold" the nested object (Department).

    Anyway. Datagrid does not support neted objects so you want to do something
    like this in the <itemtemplate> or/and <edititemtamplete>

    EG:
    <asp:label id="Label1" runat="server" Text="<%# (Container.DataItem as
    Employee.Department).name %>"></asp:label>

    Reagards
    Anders Jacobsen, Denmark
     
    Flare, Oct 30, 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. =?Utf-8?B?dWxyaWNoIHNjaHVtYWNoZXI=?=

    ASP.NET 2.0 DataBinding with object oriented business classes

    =?Utf-8?B?dWxyaWNoIHNjaHVtYWNoZXI=?=, Jun 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,466
    =?Utf-8?B?dWxyaWNoIHNjaHVtYWNoZXI=?=
    Jul 3, 2005
  2. SMichal
    Replies:
    1
    Views:
    720
    Flinky Wisty Pomm
    Oct 10, 2006
  3. jobs
    Replies:
    0
    Views:
    1,632
  4. Earl Teigrob
    Replies:
    1
    Views:
    408
    Shravan
    Mar 1, 2004
  5. Joe Rattz

    Databinding array of custom classes to DataGrid

    Joe Rattz, Apr 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    7
    Views:
    137
    Jeffrey Tan[MSFT]
    Apr 29, 2004
Loading...

Share This Page