title: DropDownList not getting selected - MVC4
body: <p>I have the DropDownList in view as below,</p>
  
  <pre><code>@Html.DropDownListFor(model =&gt; model.RoleID, (IEnumerable&lt;SelectListItem&gt;)ViewBag.RoleID, new { @class = "dropdownlistCustom" })
  @Html.DropDownList("RoleID", (IEnumerable&lt;SelectListItem&gt;)ViewBag.RoleID, new { @class = "dropdownlistCustom" })
  @Html.ValidationMessageFor(model =&gt; model.RoleID)
  </code></pre>
  
  <p>Tried both <code>DropDownList</code> and <code>DropDownListFor</code>, both are not getting the correct <code>SelectedValue</code>. </p>
  
  <p>From Controller, I am setting the <code>selectedValue</code> param (see Last parameter of SelectList()) .</p>
  
  <pre><code>public ActionResult Edit(int id = 0)
  {
      UserDetail userDetail=db.UserDetails.Find(id);
      if(userDetail!=null)
      {
         ViewBag.RoleID = new SelectList(db.Roles.Where(r =&gt; r.RoleStatus == "A"), "RoleID", "RoleName", userdetail.RoleID);
         return View(userdetail);
      }
  }
  </code></pre>
  
  <p>Model :</p>
  
  <pre><code>[Display(Name = "Name Of the Role")]
  public int RoleID { get; set; }
  [ForeignKey("RoleID")]
  public virtual Role Roles { get; set; }
  </code></pre>