0

I am using a Telerik MVC control (combobox) and I am having trouble getting the value from the model to highlight as selected when the view loads.

             <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>

I want the value in Model.CategoryDescription to show up in the Combobox as the selected entry when the page loads. So the question is how to do that.

Answered. I was able to set the SelectedIndex on the control when I built the selectList in my model and used its location for the control.

user1011441
  • 161
  • 2
  • 14

1 Answers1

0

I was able to set the SelectedIndex on the control when I built the selectList in my model and used its location for the control.

user1011441
  • 161
  • 2
  • 14