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