我正在使用带有ajax绑定的Kendo DropdownList.
使用这些代码,我无法设置来自model的初始值.它只是用项目填充列表并选择第一项.
@(Html.Kendo().DropDownList() .Name("NATIONALITY") .DataTextField("DESCRIPTION").HtmlAttributes(new { style = "width:220px" }) .DataValueField("REFERENCEID") .Value(Model.NATIONALITY) //Placeholder("SELECT") .DataSource(source => { source.Read(read => { read.Action("GetDefinitionDetails", "Definition", new { definitionCode = "NATIONALITY", addEmptyRow = false }); }).ServerFiltering(true); }).ServerFiltering(true); }))
但是当我将Html.Kendo().DropDownList()更改为Html.Kendo().Combobox()时,它还会填充列表并按预期设置初始值(这是模型传递的值).
使用最新的(可能在早期版本上工作)构建KendoUI,可以在下拉列表中设置初始Text值:
.... .Value(Model.DOCTORCODE.ToString()) //DOCTORCODE is guid type .Text(Model.DOCTOR) //DOCTOR is string type.This is optional.It should be works without .Text property