title: How to bind Complex Entity type to Gridview using ObjectDataSource
body: <p>I have an entity</p>
  
  <pre><code>class Person
  {
  public int Age{get;set;}
  public string Name{get;set;}
  public Department Dept{get;set;}
  }
  
  class Department
  {
  public int DeptId{get;set;}
  public string DeptName{get;set}
  }
  </code></pre>
  
  <p>Now I binds Collection to GridView using ObjectDataSource Control.
  Under the TemplateField for Dept of Person class looks like</p>
  
  <pre><code>&lt;EditItemTemplate&gt;
        &lt;asp:DropDownList ID="cmbStatus" DataTextField="DeptName" SelectedValue='&lt;%# Bind("Dept.DeptId") %&gt;'
            DataValueField="DeptId" runat="server" CssClass="ddl150px ddlbg" 
            DataSourceID="deptCollection" /&gt;
        &lt;asp:ObjectDataSource ID="deptCollection" runat="server" 
                     SelectMethod="GetDeptList" TypeName="LIMS.BusinessObject.Department" &gt;
       &lt;/asp:ObjectDataSource&gt;
   &lt;/EditItemTemplate&gt;
  </code></pre>
  
  <p>Now my Grid gets binded using </p>
  
  <pre><code>            &lt;asp:ObjectDataSource ID="PersonCollection" runat="server" 
                  SelectMethod="GetPersonList" 
                  TypeName="LIMS.BusinessObject.Person" 
                  DataObjectTypeName="LIMS.DomainModel.Person" 
                  DeleteMethod="Delete" InsertMethod="Create" UpdateMethod="Update" 
                  ondeleting="PersonCollection_Deleting" 
                  onupdating="PersonCollection_Updating"&gt;  
              &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>Now when I tries to update this Person entity, it throws error because dropdown displays Value field and text field and Person entity needs a Dept Entity which is actually binded to dropdownlist</p>