I'm building a website using ASP.NET and C# (web forms) and I am getting the following error when using the Entity Framework:
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: DataBinding: 'System.Data.Objects.DataClasses.EntityCollection`1[[MOSDevelopmentProjects.DAL.Allocation, MOSDevelopmentProjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a
property with the name 'OriginalAlloc'.
I just realised there is a section for Entity Framework and I was wondering if the reason I am not getting any responses is because I am asking in the wrong section.
You might be refering the wrong version of
MOSDevelopmentProjects.DAL.Allocation DLL in your project or that version of DLL has been not implemented with the propery
'OriginalAlloc'.
Thanks.
---------------------------------
/Santosh Gada
If this solved your issue, please mark as "Answered"
I did add all the tables when I was building the Entity Data Model, so I am not sure why I am getting this error.
I am adding a link to a screenshot from the Model Browser showing where the table is appearing in my data model, along with the OriginalAlloc property.
http://i48.tinypic.com/10q9se9.jpg
I'm not an expert with this so I may be missing something that would normally be obvious to someone else.
slick-asp.ne...
0 Points
28 Posts
Databinding error - does not contain a property with the name ...
Jan 22, 2013 01:18 PM|LINK
Good day,
I'm building a website using ASP.NET and C# (web forms) and I am getting the following error when using the Entity Framework:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: DataBinding: 'System.Data.Objects.DataClasses.EntityCollection`1[[MOSDevelopmentProjects.DAL.Allocation, MOSDevelopmentProjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a property with the name 'OriginalAlloc'.
My code looks like this
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Projects.aspx.cs" Inherits="MOSDevelopmentProjects.Projects" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Project List</h2> <asp:EntityDataSource ID="ProjectEntityDataSource" runat="server" ContextTypeName="MOSDevelopmentProjects.DAL.Development_ProjectsEntities" EnableDelete="True" EnableFlattening="False" EnableUpdate="True" EntitySetName="ProjectInfoes" Include="Allocations"> </asp:EntityDataSource> <asp:GridView ID="ProjectGridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" SelectedRowStyle-BackColor="LightGray" DataKeyNames="ProjectNum, CabinetAuth" DataSourceID="ProjectEntityDataSource"> <Columns> <asp:CommandField ShowSelectButton="True" ShowEditButton="True" /> <asp:TemplateField HeaderText="Project Number" SortExpression="ProjectNum"> <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProjectNum") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProjectNum") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Cabinet Authority" SortExpression="CabinetAuth"> <EditItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("CabinetAuth") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("CabinetAuth") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Minute Date" SortExpression="MinuteDate"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MinuteDate", "{0:d}") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Eval("MinuteDate", "{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Project Name" SortExpression="ProjectName"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ProjectName") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Eval("ProjectName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Date Created" SortExpression="DateCreated"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("DateCreated", "{0:d}") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label5" runat="server" Text='<%# Eval("DateCreated", "{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Last Updated" SortExpression="LastUpdated"> <EditItemTemplate> <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("LastUpdated", "{0:d}") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Eval("LastUpdated", "{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Balance" SortExpression="Balance"> <EditItemTemplate> <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Balance") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label7" runat="server" Text='<%# Eval("Balance") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Cabinet Approved Sum" SortExpression="CabinetApprSum"> <EditItemTemplate> <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CabinetApprSum") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label8" runat="server" Text='<%# Eval("CabinetApprSum") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Type" SortExpression="Type"> <EditItemTemplate> <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Type") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label9" runat="server" Text='<%# Eval("Type") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Original Allocation"> <ItemTemplate> <asp:Label ID="Label10" runat="server" Text='<%# Eval("Allocations.OriginalAlloc") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox8" runat="server" Text='<%# Eval("Allocations.OriginalAlloc") %>' Width="7em" ></asp:TextBox> </EditItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:Label ID="ErrorMessageLabel" runat="server" Text="" Visible="false" ViewStateMode="Disabled"></asp:Label> </asp:Content>The model looks like this:
Direct link to image: http://tinypic.com/r/2e2r15f/6
Hope someone can solve this.
If any more information is required to solve this problem please let me know.
Thanks.
slick-asp.ne...
0 Points
28 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 11:22 AM|LINK
Am I asking this in the wrong section?
I just realised there is a section for Entity Framework and I was wondering if the reason I am not getting any responses is because I am asking in the wrong section.
Santosh Gada
Member
151 Points
32 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 12:02 PM|LINK
Hi,
You might be refering the wrong version of MOSDevelopmentProjects.DAL.Allocation DLL in your project or that version of DLL has been not implemented with the propery 'OriginalAlloc'.
Thanks.
---------------------------------
/Santosh Gada
If this solved your issue, please mark as "Answered"
speshulk926
Participant
904 Points
204 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 01:10 PM|LINK
I see your table is called "Allocation", not "Allocations". Maybe that's your issue?
slick-asp.ne...
0 Points
28 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 01:22 PM|LINK
Hi Santosh,
In my project I have reference to this DLL as shown in the code below:
I did add all the tables when I was building the Entity Data Model, so I am not sure why I am getting this error.
I am adding a link to a screenshot from the Model Browser showing where the table is appearing in my data model, along with the OriginalAlloc property.
http://i48.tinypic.com/10q9se9.jpg
I'm not an expert with this so I may be missing something that would normally be obvious to someone else.
Thanks.
slick-asp.ne...
0 Points
28 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 01:24 PM|LINK
Hi speshulk926,
The table is called "Allocation", but the navigation property that I am using from the Data Model is called "Allocations".
Thanks.
speshulk926
Participant
904 Points
204 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 23, 2013 01:26 PM|LINK
Ahh I see that now.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 24, 2013 01:21 AM|LINK
Where?
From your given image of entity "Allocations" I cannot see that
slick-asp.ne...
0 Points
28 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 24, 2013 11:15 AM|LINK
Hi Decker,
If you look under ProjectInfo --> Navigation Properties, you will see a Navigation Property named "Allocations".
Thanks.
asp.netforum...
Member
604 Points
132 Posts
Re: Databinding error - does not contain a property with the name ...
Jan 24, 2013 11:42 AM|LINK
Check your select query.Your select query not return the coloumn.
Please post your select query.