This one’s for my reference, mostly; hopefully I don’t spend hours trying to debug this error next time.

The scenario is that you’re using an EntityDataSource to bind some entities to a ListView. Inside the ListView, you’ve got a nested data-bound control that’s trying to bind to a collection property of the current entity.

For example, you bind a list of CustomerOrder entities to the parent ListView, and then bind the collection of CustomerOrder.CustomerOrderLines to a child ListView to render the products the customer has purchased on each order.

Using the EntityDataSource in its default state gives you this:

DataBinding: 'System.Web.UI.WebControls.EntityDataSourceWrapper' does not contain a property with the name 'CustomerOrderLine'.

…and a nice big stack trace.

The issue is that we’re using the EntityDataSourceWrapper and not our actual entity. The solution? Stop using the wrapper!

Disable flattening, like this:

<asp:EntityDataSource 
    ...
    EnableFlattening="False"
	...
</asp:EntityDataSource>

Easy. Now, don’t forget about this again, future-Sam!

posted on Thursday, September 06, 2012 4:07 PM | Filed Under [ Development Microsoft ]

Comments

Gravatar
# re: DataBinding: 'System.Web.UI.WebControls.EntityDataSourceWrapper' does not contain a property with the name 'xxxx' (Ben @ 5/14/2014 11:51 AM)

Once a year or so I forget this. This time you saved me a few hours of searching. Thanks!
 
Gravatar
# re: DataBinding: 'System.Web.UI.WebControls.EntityDataSourceWrapper' does not contain a property with the name 'xxxx' (Valery Guhena @ 6/3/2016 3:02 AM)

Thank you for saving me from long sleepless nights trying to figure out the devil. Thank you very much. Wow lastly I can thing of defferent things

Post Comment

Title *
Name *
Email
Url
Comment *  
Remember me
Please add 7 and 3 and type the answer here:

Search

Site Sections

Recent Posts

Archives

Post Categories

WHS Add-In Tutorial

WHS Blogs

WHS Development