我是 MVC 的新手告诉我如何在控制器中检索选定的下拉列表值这是我将值添加到下拉列表的方式
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem { Text = "What is your Place of Birth?", Value = "What is your Place of Birth?" });
items.Add(new SelectListItem { Text = "What is your favourite Book?", Value = "What is your favourite Book?" });
items.Add(new SelectListItem { Text = "What is your childhood friend name?", Value = "What is your childhood friend name?" });
items.Add(new SelectListItem { Text = "What is your first car make and model?", Value = "What is your first car make and model?" });
items.Add(new SelectListItem { Text = "What is your favourite place?", Value = "What is your favourite place?" });
ViewData["ddlitems"] = items;
查看文件
@Html.DropDownList("ddlitems")