在选定的数据源上找不到名称相同的字段或属性

|| 我有一个实体数据模型,其中有两个实体\“ Roles \”和\“ Users \”。我有一个EntityDataSource和GridView的导航属性。 EntityDataSource指向Users实体,并具有Include = \“ Roles \”参数。 我在GridView中添加了一个BoundField,它指向RoleName(实体Roles的一个属性)。但是,当我执行代码时,出现上述错误。 我已经在另一个应用程序中成功使用了非常相似的代码。任何想法为什么这不起作用? 这是我的EntityDataSource:
    <asp:EntityDataSource ID=\"EntityDataSource1\" runat=\"server\" 
    ConnectionString=\"name=pbu_checklistEntities\" 
    DefaultContainerName=\"pbu_checklistEntities\" EnableDelete=\"True\" 
    EnableFlattening=\"False\" EnableUpdate=\"True\" EntitySetName=\"Users\" Include=\"Role\">
    </asp:EntityDataSource>
这是BoundField:
<asp:BoundField DataField=\"RoleName\" HeaderText=\"Role\" SortExpression=\"RoleName\" />
    
已邀请:
您不能将ѭ2用作相关导航属性的属性。您只能使用
asp:TemplateField
,然后将其绑定为
Eval
(而不是
Bind
)为只读。 BoundFields在内部始终使用ѭ5,这就是它不起作用的原因。我前段时间不得不自己弄清楚: 一个带有EntityDataSource的ASP.NET GridView中两个相关数据库表的列     

要回复问题请先登录注册