How to set default value for html.dropdownlist

Setting default value of a Html.DropDownList()

MVC : How To Set Default Value For Html.dropdownlist

ASP.NET MVC Html.DropDownList SelectedValue

Html.DropDownList selected value problem

ASP.NET MVC Html.DropDownList Not Showing Selected Value


Type Following Code in your controller

List<SelectListItem> Gender = new List<SelectListItem>();
Gender.Add(new SelectListItem { Text = “Male”, Value = “Male” });
Gender.Add(new SelectListItem { Text = “Female”, Value = “Female” });
ViewBag.Gender1 = new SelectList(Gender, “Value”, “Text”, “Female”);

Type Following Code in your View

@Html.DropDownList(“Gender”, ViewBag.Gender1 as SelectList)