Dav*_*key 6 vb.net asp.net linq-to-entities entity-framework entity-framework-4
我有一个实体数据模型,其中包含两个实体"角色"和"用户".我有一个导航属性,我有一个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>
Run Code Online (Sandbox Code Playgroud)
这是BoundField:
<asp:BoundField DataField="RoleName" HeaderText="Role" SortExpression="RoleName" />
Run Code Online (Sandbox Code Playgroud)
Sla*_*uma 20
您不能将asp:BoundField
a用作相关导航属性的属性.您只能使用a asp:TemplateField
然后将其绑定为readonly with Eval
(not Bind
).BoundFields总是在Bind
内部使用,这就是它无法工作的原因.我不得不在不久前解决这个问题:
一个带有EntityDataSource的ASP.NET GridView中的两个相关数据库表的列
归档时间: |
|
查看次数: |
30014 次 |
最近记录: |