none
Want to Display Property of other Class in the Grid View RRS feed

  • Question

  • Hi Team,

    I am uses Entity Framework POCO Model with Object Data Source. for the Northwind Database.
    for a testing i have  use Customer, Order & OrderDetail.
    Now, After generating that from POCO Template, it gives me all these 3 classes. Now, I want to bind the GridView for All Order List. Where i also want the Customer Name.

    So, Here is my sample Code

     <asp:ObjectDataSource ID="odsOrderList" runat="server" SelectMethod="ReadAllOrder"
                        TypeName="EF.BusinessLayer.OrderMaster"></asp:ObjectDataSource>
                    <asp:GridView ID="gvOrderList" runat="server" DataSourceID="odsOrderList" AutoGenerateColumns="false">
                    <Columns>
                    <asp:BoundField DataField="OrderID" HeaderText="Order ID" />
                    <asp:BoundField DataField="OrderDate" HeaderText="Order Date" />
                    <asp:BoundField DataField="Customer.ContactName" HeaderText="Customer" />
                    </Columns>
                    </asp:GridView>

     WHERE I have Order & Customer Both are different Classes generated from POCO Template.
    In Order Class i have Customer Object. but I don't know How to take Customer.ContactName from Customer Class while binding Order.


    Thanks & Regards, Brijesh Shah
    Tuesday, June 28, 2011 10:37 AM

Answers