title: MVC3 - Two models in one View - Error - How to classify
body: <p>I would like to use two models in one view. For that I have the following set up. 
  In a single .cs file  I have the following model code:</p>
  
  <pre><code>public class Class1   
  {
     //List of atttributes 1.
  }
  
  public class Class2   
  {
     //List of atttributes 2.
  }
  
  
   public class ParentView
  {
     public Class1 Class1{get; set;}
     public Class2 Class2{get; set;}
  
  }
  </code></pre>
  
  <p>To make use of these two classes in one view I reference </p>
  
  <pre><code>@model IEnumerable&lt;Project.Models.ParentView&gt; 
  </code></pre>
  
  <p>in the View .cshtml page. and In my view code there is this code that is breaking up .. I get an error saying - "The models.parentview does not have a definition of Class1Attribute and no extension method.....etc.." How can I classify the statement below so that it recognizes the attribute. </p>
  
  <pre><code>@foreach (var item in Model)
    {
  
          @Html.DisplayFor(modelItem =&gt; item.Class1Attribute)
  
          @Html.DisplayFor(modelItem =&gt; item.Class1Atttribute)    
  
  
    }
  </code></pre>
  
  <p>thanks for your help.</p>