我想將選定的下拉選項發送到model.Feit 假設,我需要DropDownListFor,然後選擇表,然後下拉..?C#MVC ASP.NET DropDownListFor
//here's my drop down menu in my controller
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem { Text = "Owner", Value = "0", Selected = true });
items.Add(new SelectListItem { Text = "Leader", Value = "1" });
ViewBag.items = items;
//this works fine, but the selected option has to be inserted into my database when submitted
//the first line shows the label
<div class="editor-label">@Html.LabelFor(model => model.Feit)</div>
//the second line needs to show as a dropdownlist with the 2 options above here
<div class="editor-field">@Html.DropDownListFor(model => model.Feit, "items")</div>
//when the option is selected, and submit is pressed this has to be sent to the db
// this works for all other fields, but my syntax is wrong at , "items"
請更詳細地解釋你正在做什麼以及問題是什麼。 – 2014-10-09 14:21:29
頂部有一個下拉列表(在控制器中) 在底部(在我的create.cshtml頁面中),需要有一個下拉菜單和這些選項。這些,選中時必須放入model => model.Feit。 但是我認爲我的語法不正確,最後一行 – SNT 2014-10-09 14:27:33