0

Telerik MVC コントロール (コンボボックス) を使用していますが、モデルから値を取得して、ビューの読み込み時に選択されたものとして強調表示するのに問題があります。

             <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.CategoryDe​​scription の値が選択されたエントリとしてコンボボックスに表示されるようにします。そこで問題はそれをどうするかです。

答えた。モデルでselectListを構築し、その場所をコントロールに使用したときに、コントロールにSelectedIndexを設定できました。

4

1 に答える 1

0

モデルでselectListを構築し、その場所をコントロールに使用したときに、コントロールにSelectedIndexを設定できました。

于 2012-05-11T14:56:42.197 に答える