views:

172

answers:

1

I have a DataGridView bound to an entity framework object called "Person". All the main fields of person such as Name etc show correctly, but the fields that are referenced to child tables (e.g. "Place of Birth") only show the entity name/type in the datagridview.

How do I navigate through to correctly show the values of child entities in a DataGridView?

A: 

One option is to set the datasource on another bindable element in your gridview. For example I have a template field with a datalist that gets bound to an array:

<asp:DataList ID="childList" runat="server" DataSource='<%#Eval("ChildProperty") %>' >
    <ItemTemplate>
        <%# Container.DataItem %>
    </ItemTemplate>
</asp:DataList>

The datalist's datasource is set to the parent property I want to bind to. When the grid is bound, the datalist will be bound as well.

BStruthers
Unfortunately I don't have a bindable element called place of birth in my Person table - its in a child table and that is the whole problem
Calanus