This is not necessarily a LLBLGen problem, but it is something that I often run up against and thought someone may have found a nice solution to it.
When displaying a collection in a grid, is there an easy way to display the value of a property of a related object property of one of the elements in the collection?
ie: OrdersCollection in grid but want to display order.Customer.CompanyName in the grid, rather than CustomerID.
Example:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ordersEntityCollection"
DataKeyNames="OrderId" AllowPaging="True" PageSize="5">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ShipAddress" HeaderText="ShipAddress" SortExpression="ShipAddress" />
<asp:BoundField DataField="ShipName" HeaderText="ShipName" SortExpression="ShipName" />
<asp:BoundField DataField="ShipCountry" HeaderText="ShipCountry" SortExpression="ShipCountry" />
<asp:BoundField DataField="CustomerId" HeaderText="CustomerId" SortExpression="CustomerId" />
<asp:BoundField DataField="ShipRegion" HeaderText="ShipRegion" SortExpression="ShipRegion" />
<asp:BoundField DataField="ShipCity" HeaderText="ShipCity" SortExpression="ShipCity" />
<asp:BoundField DataField="OrderId" HeaderText="OrderId" SortExpression="OrderId" />
<asp:BoundField DataField="ShipPostalCode" HeaderText="ShipPostalCode" SortExpression="ShipPostalCode" />
</Columns>
</asp:GridView>
In the above example, I would like to replace:
<asp:BoundField DataField="CustomerId" HeaderText="CustomerId"/>
With something like:
<asp:BoundField DataField=".Customers.CompanyName" HeaderText="Customer Name"/>
So instead of the CustomerID being shown, we can see their name.
True, a simpler (and more efficient) way of doing it would be to define a Typed List, however, in one-off situations I would rather not have to define a new list, not to mention that they are read only.
Any ideas?