【发布时间】:2018-07-17 16:40:33
【问题描述】:
我的视图中定义了一个剑道下拉列表,如下所示:
@(Html.Kendo().DropDownList()
.Name("RowCategoryID")
.OptionLabel("Select Row Category...")
.BindTo(new SelectList(Model.RowCategories.Select(r => new { Key = r.Key, Value = r.Value }), "Key", "Value"))
.HtmlAttributes(new { style = "width: 50%" })
我的模型有一个名为 RowCategories 的 Dictionary<int,string>,其中包含 DDL 的键/值对。它还有一个名为RowCategoryID 的int 属性,表示从RowCategories 列表中选择的当前RowCategory。
DDL 使用来自RowCategories 的值进行填充,但它不会选择值为RowCategoryID 的选项。它只是默认为“选择行类别...”。
如何让它选择值为RowCategoryID的选项?
【问题讨论】:
标签: asp.net-mvc kendo-ui kendo-asp.net-mvc