Binding Grid View to Objects??

N

Nemisis

Hi everyone,

I have now managed to write my own data layer and business layer
objects, mapped them out etc etc, and it all works fine.

The problem i am having is that my business object consist of other
business objects, example below

Object1
id
name
object2
object3collection

Object2 has properties and object3 is a collection of another object.
How in the grid view can i show the values of these fields??

I have tried object2.id, and object3collection.item(0).id, but it
doesnt work. i know there are objects within the collection because i
always add one, even if there isnt one (for testing)

Very grateful for any help. Cheers
 
G

Guest

If you want a datagrid that shows a bunch of Object1 types then your
ItemTemplate would be (these are all slightly different and assuming that
you're doing C# 2.0)....

<asp:label runat="server" id="id" Text="<%# (Container.DataItem as
Object1).Id.ToString() %>"/>
<asp:label runat="server" id="Name" Text="<%# (Container.DataItem as
Object1).name %>"/>
<asp:label runat="server" id="SomePropertry" Text="<%# (Container.DataItem
as Object1).Object2.PropertyName %>"/>
<asp:label runat="server" id="SomePropertry" Text="<%# (Container.DataItem
as Object1).Object3Collection[0].PropertyName %>"/>


<asp:DataGrid runat="server" id="Object3Grid" DataSource="<%#
(Container.DataItem as Object1).Object3Collection %>"/>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top