I have an Entity Data Model with two entities in it "Roles" and "Users". There is a navigation property from I have a EntityDataSource and a GridView. The EntityDataSource points to the Users entity and has an Include="Roles" parameter.
I've added a BoundField in the GridView that points to RoleName, a property of the entity Roles. However, when I execute the code I get the above error.
I have used very similar code successfully in another application. Any ideas why this isn't working?
Here is my EntityDataSource:
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
EnableFlattening="False" EnableUpdate="True" EntitySetName="Users" Include="Role">
<asp:BoundField DataField="RoleName" HeaderText="Role" SortExpression="RoleName" />
You cannot use an
asp:BoundField for a property of a related navigation property. You can only use an
asp:TemplateField and then bind it as readonly with
Bind). BoundFields are always using
Bind internally, that's the reason why it doesn't work. I had to figure this out myself some time ago: