Entity Framework: How to bind related products
Posted
by Waheed
on Stack Overflow
See other posts from Stack Overflow
or by Waheed
Published on 2010-03-16T06:04:59Z
Indexed on
2010/03/16
6:06 UTC
Read the original article
Hit count: 824
I am using the following Linq query
from p in Product.Include("ProductDetails.Colors")
where p.ProductID.Equals(18)
select p;
And then using the result of this query to bind the GridView.
The productDetails are bind to the grid fine, but the Colors are not bind. To bind colors i am using <%# Eval("Colors.CategoryName") %>. Error is " Field or property with the name 'Colors.CategoryName' was not found on the selected data source."
But in a loop i am getting this fine.
foreach (ProductDetails proDet in pd.ProductDetails)
{
string bar = proDet.BarCode;
string color = proDet.Colors.CategoryName;
}
© Stack Overflow or respective owner