Razor 如何使Telerik组合框显示与SelectList中的值相对应的模型字段中的值?
我使用的是Telerik MVC控件组合框,当视图加载时,我很难从模型中获取要高亮显示的值Razor 如何使Telerik组合框显示与SelectList中的值相对应的模型字段中的值?,razor,telerik-mvc,asp.net-mvc-3-areas,Razor,Telerik Mvc,Asp.net Mvc 3 Areas,我使用的是Telerik MVC控件组合框,当视图加载时,我很难从模型中获取要高亮显示的值 <tr> <td class="editor-label"> @Html.LabelFor(model => model.CategoryDescription) </td> <td class="editor-field">
<tr>
<td class="editor-label">
@Html.LabelFor(model => model.CategoryDescription)
</td>
<td class="editor-field">
@Html.DisplayFor(model => model.CategoryDescription)
</td>
<td>
@(Html.Telerik().ComboBoxFor(model => model.CategoryDescription)
.BindTo((SelectList)(Model.CategoryDescriptionList))//(SelectList)(ViewBag.CategoriesList))
.HtmlAttributes(new { style = "width:350px; white-space:nowrap;" })
.HighlightFirstMatch(true)
.Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
.ClientEvents(events => events.OnClose("ComboBox_OnClose"))
)
@Html.ValidationMessageFor(model => model.CategoryDescription)
</td>
</tr>
我希望Model.CategoryDescription中的值在页面加载时作为所选条目显示在组合框中。所以问题是如何做到这一点
回答。
当我在模型中构建selectList并将其位置用于控件时,我能够在控件上设置SelectedIndex。当我在模型中构建selectList并将其位置用于控件时,我能够在控件上设置SelectedIndex