错误:EntitySet“建筑物”容器上不存在页面标记中指定的内容
我已经在 GridView 中像这样设置了 ItemTeplate:
<asp:TemplateField HeaderText="Building">
<ItemTemplate>
<asp:Label
ID="lblBuilding"
Text='<%# Bind("Building1.building_name") %>'
runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:EntityDataSource
ID="EditHousingDataSource"
runat="server"
EnableDelete="true"
ConnectionString="name=pbu_housingEntities"
DefaultContainerName="pbu_housingEntities"
EnableFlattening="false"
EntitySetName="Building"
EntityTypeFilter="Building" />
<asp:DropDownList
ID="ddlBuilding"
runat="server"
DataSourceID="EditHousingDataSource"
DataTextField="building_name"
DataValueField="ID" />
</EditItemTemplate>
</asp:TemplateField>
我收到错误:
容器上不存在页面标记中指定的 EntitySet“Building”。
有什么想法吗? pbu_housingEntities中肯定有一个Building实体?
I've setup an ItemTeplate like so in a GridView:
<asp:TemplateField HeaderText="Building">
<ItemTemplate>
<asp:Label
ID="lblBuilding"
Text='<%# Bind("Building1.building_name") %>'
runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:EntityDataSource
ID="EditHousingDataSource"
runat="server"
EnableDelete="true"
ConnectionString="name=pbu_housingEntities"
DefaultContainerName="pbu_housingEntities"
EnableFlattening="false"
EntitySetName="Building"
EntityTypeFilter="Building" />
<asp:DropDownList
ID="ddlBuilding"
runat="server"
DataSourceID="EditHousingDataSource"
DataTextField="building_name"
DataValueField="ID" />
</EditItemTemplate>
</asp:TemplateField>
I'm receiving the error:
EntitySet 'Building' that was specified in page markup does not exist on the Container.
Any ideas on why? There is definitely a Building entity in the pbu_housingEntities?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里……
您不必指定实体的类名称,而是指定派生的 ObjectContext 的
ObjectSet
属性的名称。这可能被称为
建筑物
。您可以在 edmx 模型配置或派生的 ObjectContext 生成的文件中检查这一点。Here ...
... you don't have to specify the class name of your entity but the name of the
ObjectSet<Building>
property of your derived ObjectContext.This might be called
Buildings
. You can check this in your edmx model configuration or in the generated file for your derived ObjectContext.