title: ASP.MVC - Multiple models in one view using default view engine - how to?
body: <p>I'm just getting into ASP.NET MVC, and am not sure how to solve the following issue which has come up in an excercise in a text book:</p>
  
  <p>I have a View as below that is currently bound to a model "ShippingDetails". The View / Controller uses model binding to map the form fields that currently exist back to the ShippingDetails model.</p>
  
  <p>I want to be able to use a second model here for credit card data, but am not sure how to start off. Do I need to create a container object and use that as the model?</p>
  
  <p>I presume this would break the model binding that exists, as the form data won't map directly on to a property of the model?</p>
  
  <p>I've found a post (http://stackoverflow.com/questions/4764011/multiple-models-in-a-view) that addresses the same issue in a different View engine, but I'd prefer to learn using the default view first off.</p>
  
  <p>I've also seen examples using view data, but this doesn't appear that elegant.</p>
  
  <p>How do I go about what I am trying to achieve here?</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;SportsStore.DomainModel.Entities.ShippingDetails&gt;" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      SportsStore: Check Out
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Check out now&lt;/h2&gt;
  
      Please enter your details, and we'll ship your goods right away!
  
      &lt;%= Html.ValidationSummary() %&gt;
  
      &lt;%
          using (Html.BeginForm()) { %&gt;
  
          &lt;h3&gt;Ship to&lt;/h3&gt;
  
          &lt;div&gt;Name: &lt;%= Html.TextBox("Name") %&gt;&lt;/div&gt;
  
          &lt;h3&gt;Address&lt;/h3&gt;
  
          &lt;div&gt;Line 1: &lt;%= Html.TextBox("Line1") %&gt;&lt;/div&gt;
          &lt;div&gt;Line 2: &lt;%= Html.TextBox("Line2") %&gt;&lt;/div&gt;
          &lt;div&gt;Line 3: &lt;%= Html.TextBox("Line3") %&gt;&lt;/div&gt;
          &lt;div&gt;City: &lt;%= Html.TextBox("City") %&gt;&lt;/div&gt;
          &lt;div&gt;State: &lt;%= Html.TextBox("State") %&gt;&lt;/div&gt;
          &lt;div&gt;Zip: &lt;%= Html.TextBox("Zip") %&gt;&lt;/div&gt;
          &lt;div&gt;Country: &lt;%= Html.TextBox("Country") %&gt;&lt;/div&gt;
  
          &lt;h3&gt;Options&lt;/h3&gt;
  
          &lt;%= Html.CheckBox("GiftWrap") %&gt; Gift wrap these items
  
          &lt;p align="center"&gt;&lt;input type="submit" value="Complete Order" /&gt;&lt;/p&gt;
  
      &lt;%
          }
      %&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>