Lets say I m working on Northwind like database
I have
Customers
Orders
And OrderDetails table.
I'm binding Customers table "collection" to the asp.net gridview
Just for the records, your example should be reversed. I mean you should say you are binding OrderDetails and you want to display a field from the Customer.
Because the Customer has many Orders and the Order has many OrderDetails, so f you are binding to a Customer, then which OrderID would you like to display, similarly to the OrderDetails.
But When you are binding to the many-side of a many to one relation, then you only have one entity at the other side to bind to.
Anyway please use something like:
<asp:TemplateField HeaderText="Customer" SortExpression="ProductName">
<ItemTemplate>
<asp:Label ID="Product" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Order.Customer.CompanyName")%>' />
</ItemTemplate>
</asp:TemplateField>
Please note that you should supply a prefetchPath to the same dsitination to the DataSource.
For the above example you should set the LLBLGenProDataSource.PrefetchPathToUse as follows:
OrderDetailsDS.PrefetchPathToUse = new PrefetchPath((int)EntityType.OrderDetailEntity);
OrderDetailsDS.PrefetchPathToUse.Add(OrderDetailEntity.PrefetchPathOrder).SubPath.Add(OrderEntity.PrefetchPathCustomer);