title: Dropdown list better as ViewBag or part of model C#/.NET MVC4
body: <p>Probably simple, but I seem to be missing something.</p>
  
  <p>Two Models:</p>
  
  <pre><code>public class Hardware
  {
      [Required]
      public int Id { get; set; }
  
      public int SerialNum { get; set; }
      public int ProductNum { get; set; }
      public string Notes { get; set; }
      public DateTime PurchaseDate { get; set; }
      public DateTime WarrantyExpiration { get; set; }
  
      public virtual Manufacturer Manufacturer { get; set; }
  }
  
  public class Manufacturer
  {
      public int Id { get; set; }
  
      [Required]
      public string Name { get; set; }
  
      public virtual ICollection&lt;Hardware&gt; Hardware { get; set; }
  }
  </code></pre>
  
  <p>When I go to the Hardware Create view, I want to to be able to select from a dropdown of Manufacturers, and when it submits it should establish a relationship between the piece of hardware and the select Manufacturer.</p>
  
  <p>At the moment, I've been using the following to build a selectList in the controller</p>
  
  <pre><code>SelectList selectList = new SelectList(db.Manufacturers, "Id", "Name");
  ViewBag.selectList = selectList;
  </code></pre>
  
  <p>And then casting it in the view:</p>
  
  <pre><code>@Html.DropDownListFor(model =&gt; model.Manufacturer, ViewBag.selectList as SelectList)\
  </code></pre>
  
  <p>However, it seems like there should be a better way to do this - perhaps creating a viewModel that inherits from Hardware with a SelectList typed property?</p>