我不知道如何确定在我的剑道下拉列表中选择了哪个项目。我的观点将其模型定义为:
@model KendoApp.Models.SelectorViewModel
ViewModel 定义为:
public class SelectorViewModel
{
//I want to set this to the selected item in the view
//And use it to set the initial item in the DropDownList
public int EncSelected { get; set; }
//contains the list if items for the DropDownList
//SelectionTypes contains an ID and Description
public IEnumerable<SelectionTypes> ENCTypes
}
在我看来,我有:
@(Html.Kendo().DropDownList()
.Name("EncounterTypes")
.DataTextField("Description")
.DataValueField("ID")
.BindTo(Model.ENCTypes)
.SelectedIndex(Model.EncSelected)
)
这个 DropDownList 包含我期望的值,但是当用户单击提交按钮时,我需要将选定的值传递回我的控制器。一切正常,除了我无法访问从控制器的 [HttpPost] 操作中选择的项目。那么,如何将 DropDownList 的值分配给隐藏的表单字段,以便控制器可以使用它?