title: MVC3 Razor > Make Model IEnumerable, so it can be used in View?
body: <p>I have this model:</p>
  
  <pre><code>namespace easyBooking.Models
  {
      public class CardInfo
      {
          public string name { get; set; }
          public string adress { get; set; }
          public string zipcode { get; set; }
          public string city { get; set; }
          public string ccsID { get; set; }
          public string birthday { get; set; }
          public string nationalitet { get; set; }
          public string cardType { get; set; }
      }
  }
  </code></pre>
  
  <p>which I populate from a function and return to the controller. The problem is that I cannot hand this model to my view, since it does not implement IEnumerable... Instead I have to add information to the viewBag like this:</p>
  
  <pre><code>var cardInfo = FunctionLib.cardCampingPas(myArray);
                          ViewData.Add("name", cardInfo.name);
                          ViewData.Add("adress", cardInfo.adress);
                          ViewData.Add("nationalitet", cardInfo.nationalitet);
                          ViewData.Add("ccsID", cardInfo.ccsID);
                          ViewData.Add("zipcode", cardInfo.zipcode);
                          ViewData.Add("city", cardInfo.city);
                          ViewData.Add("cardType", cardInfo.cardType);
                          return View("../Reservation/New", ViewData);
  </code></pre>
  
  <p>which is kind of stupid, when I should be able to just add the cardInfo model directly to the View.</p>
  
  <pre><code>    var cardInfo = FunctionLib.cardCampingPas(myArray);
      return View("../Reservation/New", cardInfo);
  </code></pre>
  
  <p>So basically I just need to pass a bunch of strings to the view. How can my model CardInfo be accessed directly from my view?</p>
  
  <p><strong>Update</strong></p>
  
  <p>@rene - view data where I added a @model declaration. I did get some errors when I tried it last, but it must have been because I tried to <code>foreach</code> it or something.. now... just no error, and I have no idea if anything is passed to the view or how to get the data.</p>
  
  <pre><code>@model easyBooking.Models.CardInfo
  @{
      ViewBag.Title = "New";
  }
  &lt;h2&gt;Ny reservation&lt;/h2&gt;
  &lt;p&gt;Benyttet kort: @Model.cardType&lt;/p&gt;
  </code></pre>
  
  <p>This now works...</p>