I have an entity called Employee that has a Navigation Property called Groups. I have an entity called Group that is related to an Employee and has fields for Name and Description
I have an EntityDataSource to filter by the Employee selected in GridView1, that has Include Groups, its defined like this:
<asp:EntityDataSource ID="GroupsByEmployeeSource" runat="server" ConnectionString="name=SafetyContext" DefaultContainerName="SafetyContext" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="Employees" Include="Groups" Where="it.[EID] == @EmpID">
<WhereParameters>
<asp:ControlParameter Name="EmpID" Type="Int32" ControlID="GridView1" PropertyName="SelectedDataKey.Value" />
</WhereParameters>
</asp:EntityDataSource>
GridView3 is used to display the Groups that the Employee belongs to. I have it set up like this:
<asp:GridView runat="server" ID="GridView3" DataSourceID="GroupsByEmployeeSource" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="GroupsByEmployee" runat="server" Text='<%#Eval("Groups.Name") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And every time I select an employee in GridView1 the follow exception is thrown:
System.Web.HttpException: DataBinding: 'System.Collections.Generic.HashSet`1[[SafetyTrackingConceptApplication.DAL.Group, SafetyTrackingConceptApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a property with the name 'Name'.
I must be missing something, but the Entity Group definitely has a property called Name. Does anyone have any idea what is wrong here?