我有MultiSelect
属于Kendo ListView
EditorTemplates。当我想提交选定的MultiSelect
值时,我获得了所选项目列表,但所有项目都填充了0值。我无法获得所选项目的正确值。
这是我的ListView:
@(Html.Kendo().ListView<esCMS.Modules.C2C.Domain.c2cFieldRangeList>()
.Name("listView")
.TagName("div")
.ClientTemplateId("template")
.DataSource(dataSource => dataSource
.Model(model => model.Id(x => x.FieldRangeID))
.PageSize(6)
.Create(create => create.Action("AddRange", "Field"))
.Update(update => update.Action("UpdateRange", "Field"))
.Read(read => read.Action("ReadRange", "Field", new { id = Model.FieldID }))
))
这是我的EditorTemplates:
<table>
<tr>
<td>
@Html.LabelFor(x => x.RangeValue)
</td>
<td>
:
</td>
<td>
@Html.TextBoxFor(x => x.RangeValue, new { @class = "k-textbox", style = "width:180px" })
<span data-for="RangeValue" class="k-invalid-msg"></span>
</td>
</tr>
<tr>
<td>
@Html.LabelFor(x => x.SelectedValues)
</td>
<td>
:
</td>
<td>
@(Html.Kendo().MultiSelectFor(x=> x.SelectedValues)
.HtmlAttributes(new { style = "width:180px" })
.BindTo(new SelectList(ViewBag.Fields, "FieldID", "Title")))
</td>
</tr></table>
修改: ViewBag.Fields
包含c2cFieldList
模型的列表,我希望在提交视图时获得FieldID
的列表。
ViewBag.Fields = Entities.c2cField.Where(x => !x.IsGeneral && !x.IsTemp).Select(x => new c2cFieldList { Title = x.Title, FieldID = x.FieldID});
任何建议都会有所帮助。