databinding & classes

B

Bart

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 ?
 
F

Flare

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top