In order to get dropdown value, wrap your select list in a form tag. Use models and DropDownListFor
helper
Razor View
@model MyModel
@using (Html.BeginForm("MyController", "MyAction", FormMethod.Post)
{
@Html.DropDownListFor(m => m.Gender, MyModel.GetGenderValues())
<input type="submit" value="Send" />
}
Controller and other classes
public class MyController : Controller
{
[HttpPost]
public ActionResult MyAction(MyModel model)
{
// Do something
return View();
}
}
public class MyModel
{
public Gender Gender { get; set; }
public static List<SelectListItem> GetGenderValues()
{
return new List<SelectListItem>
{
new SelectListItem { Text = "Male", Value = "Male" };
new SelectListItem { Text = "Female", Value = "Female" };
};
}
}
public enum Gender
{
Male, Female
}
And if you use partial view, simply pass your model in it:
@Html.Partial("MyPartialView", Model)