title: ASP MVC 3 DropDown list in Edit View
body: <p>Hi guys in new with asp mvc, so i having problem with the DropDown in edit view:</p>
  
  <pre><code>The ViewData item that has the key 'ProvinciaID' is of type 'System.Int32' but must be of type 'IEnumerable&lt;SelectListItem&gt;'.
  </code></pre>
  
  <h1>Provincia Model:</h1>
  
  <pre><code>public class Provincia
      {
          public int ProvinciaID { get; set; }
          [DisplayName("Provincia")]
          [Required(ErrorMessage = "Provincia es requerida")]
          public string ProvinciaNombre { get; set; }
      }
  </code></pre>
  
  <h1>Registro Model:</h1>
  
  <pre><code>public class Registro
      {
          public int ID { get; set; }
          ....
  
          [DisplayName("Provincia")]
          [Required]
          public int ProvinciaID { get; set; }
          public List&lt;Provincia&gt; rProvincia { get; set; }
          ....
  }
  </code></pre>
  
  <h1>Controller</h1>
  
  <pre><code>public ActionResult Edit(int id)
          {
              Registro registro = db.Registros.Find(id);
  
              ViewBag.provincias = new SelectList(db.Provincias, "ProvinciaID", "ProvinciaNombre", registro.ProvinciaID);            
  
              return View(registro);
          }
  </code></pre>
  
  <h1>View</h1>
  
  <pre><code>&lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.ProvinciaID)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.DropDownList("ProvinciaID", (IEnumerable&lt;SelectListItem&gt;)ViewData["provincias"]))
              @Html.ValidationMessageFor(model =&gt; model.ProvinciaID)
          &lt;/div&gt;
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Thanks guys</p>