title: how to set the selected value in dropdownlist mvc
body: <p>I have a dropdown in <code>View</code></p>
  
  <pre><code>@Html.DropDownList("GenderAllowed", (SelectList)ViewBag.LocGenederAllowedList, new { @class = "form-control" })
  </code></pre>
  
  <p>and I am sending list of dropdown through <code>ViewBag</code>, and through model I am sending value that need to be selected in the dropdown.</p>
  
  <p>But the value in dropdown is not selected.</p>
  
  <p>My Controller</p>
  
  <pre><code>[HttpGet]
      public ActionResult EditVendorLocation(int VendorLocationID)
      {
          VendorLocationHandler obj = new VendorLocationHandler();
          LocationGrid objLoc = new LocationGrid();
          FillGenederAllowed(objLoc);
          objLoc = obj.GetVendorLocationForAdmin(VendorLocationID);
  
          return View(objLoc);
      }
  </code></pre>
  
  <p>Function for Viewbag</p>
  
  <pre><code>public void FillGenederAllowed(LocationGrid V)
  {
      Dictionary&lt;int, string&gt; LocGenederAllowed = EnumHelper.GetGenderStates();
      SelectList LocGenederAllowedList = new SelectList(LocGenederAllowed, "key", "value");
      ViewBag.LocGenederAllowedList = LocGenederAllowedList;
  }
  </code></pre>