I have two Entity classes: Order and OrderItem. Order contains a navigation property OrderItemSet of type
System.Data.Objects.DataClasses.EntityCollection<OrderItem>
On an aspx page is a FormView bound to this EntityDataSource:
<asp:EntityDataSource ID="EntityDataSourceOrder" runat="server"
ConnectionString="name=EntitiesContext"
DefaultContainerName="EntitiesContext"
EntitySetName="Order"
Include="OrderItemSet"
// stuff to define a query
</asp:EntityDataSource>
The FormView is bound to the DataSource and the ItemTemplate of this FormView contains a ListView which I try to bind to the OrderItemSet. It looks this way:
<asp:FormView ID="FormViewOrder" runat="server" DataKeyNames="OrderID"
DataSourceID="EntityDataSourceOrder" AllowPaging="True" >
<ItemTemplate>
...
<asp:ListView ID="ListViewOrderItems" runat="server"
DataSource='<%# Eval("OrderItemSet")%>' >
...
</asp:ListView>
</ItemTemplate>
</asp:FormView>
When I run the application I get an exception pointing to the line DataSource='<%# Eval("OrderItemSet")%>' in markup and telling me:
DataBinding: System.Web.UI.WebControls.EntityDataSourceWrapper does not contain a property with name 'OrderItemSet'
What is wrong here?
(I've done the same with other navigation properties which are not lists but single object references, and that works.)
Thank you for help!