title: The ViewData item with the key "KEY" is a "System.Int32" but must be of type 'IEnumerable <SelectListItem> "
body: <p>The ViewData item with the key "roleID" is a "System.Int32" but must be of type 'IEnumerable  ".</p>
  
  <p>I cant fix it 
  <strong>Please i need your help!!  This is my code:</strong> </p>
  
  <p>admin Model:</p>
  
  <pre><code> [Key]
      public int adminID { get; set; }
  
      [DisplayName("Role")]
      public int roleID { get; set; }
      public virtual Role roles { get; set; }
  
      [Required(ErrorMessage ="Le nom est obligatoire.")]
      public string Nom { get; set; }
  
      [Required(ErrorMessage = "Le prenom est obligatoire.")]
      public string Prenom { get; set; }
  
      [Required(ErrorMessage = "L'email est obligatoire.")]
      [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "email n'est pas valide.")]
      [DataType(DataType.EmailAddress)]
      [Remote("IsEmailAdminExist", "Admin", ErrorMessage = "URL exist!")]
      public virtual  string Email { get; set; }
  
      [Required(ErrorMessage = "Le mot de pass est obligatoire.")]
      [DataType(DataType.Password)]
      public string Pass { get; set; }
  
      public string Photo { get; set; }
  
      [NotMapped]
      public HttpPostedFileBase PhotoUpload{ get; set; }
  </code></pre>
  
  <p>role Model:</p>
  
  <pre><code>[Key]
  public int roleID { get; set; }
  
  [Required(ErrorMessage = "Le nom est obligatoire.")]
  public string Nom { get; set; }
  
  public virtual ICollection&lt;Admin&gt; Admins { get; set; }
  </code></pre>
  
  <p>Admin Controller:</p>
  
  <p>GET :  </p>
  
  <pre><code>// GET: Admin/Edit/5
              public ActionResult Edit(int id)
              {
                  var data = from p in AdminContext.roles
                             select new
                             {
                                 roleID = p.roleID,
                                 roleNom = p.Nom
                             };
  
                  SelectList list = new SelectList(data, "roleID", "roleNom");
                  ViewBag.Roles = list;
  
  
                  Admin admin = AdminContext.admins.Where(x =&gt; x.adminID == id).SingleOrDefault();
                  if (admin != null)
                  {
                      return View("~/Views/Administration/Admin/Edit.cshtml", admin);
                  }
                  else
                  {
                      return HttpNotFound();
                  }
              }
  </code></pre>
  
  <p>POST:</p>
  
  <pre><code>// POST: Admin/Edit/5
          [HttpPost]
          public ActionResult Edit(Admin model)
          {
              Admin admin = AdminContext.admins.Where(x =&gt; x.adminID == model.adminID).SingleOrDefault();
              ModelState.Remove("Pass");
              if (ModelState.IsValid)
              {
                  if (admin != null)
                  {
                      if (model.PhotoUpload != null &amp;&amp; model.PhotoUpload.ContentLength &gt; 0)
                      {
                          var extension = Path.GetExtension(model.PhotoUpload.FileName);
                          var filename = model.adminID + extension;
                          var path = Path.Combine(Server.MapPath("~/Content/TemplateAdmin/assets/upload/admins"), filename);
                          model.PhotoUpload.SaveAs(path);
                          model.Photo = "/Content/TemplateAdmin/assets/upload/admins/" + filename;
                      }
                      else
                      {
                          model.Photo = admin.Photo;
                      }
                      if (model.Pass == null &amp;&amp; model.Pass != "")
                          model.Pass = admin.Pass;
  
                      AdminContext.Entry(admin).CurrentValues.SetValues(model);
                      AdminContext.SaveChanges();
                  }
              }
              //tempdata
              return View("~/Views/Administration/Admin/Edit.cshtml", model);
          }
  </code></pre>
  
  <p>Edit View:</p>
  
  <pre><code>                        &lt;div class="form-group"&gt;
                              &lt;label class="control-label"&gt;
                                  Role &lt;span class="symbol required"&gt;&lt;/span&gt;
                              &lt;/label&gt;
                              @Html.DropDownListFor(m =&gt; m.roleID, ViewBag.Roles as SelectList, "Selectioner un role", new { @class = "form-control search-select", id = "roleID" })
                          &lt;/div&gt;
  </code></pre>