当 CKEditor 也在页面上使用时 DropDownList 出错
Error with DropDownList when CKEditor is also in use on page
我有一个工作正常的下拉列表,但是当我将 CKEditor
(ckeditor-standard 4.5.7)添加到 handel EditorFor
助手时,我收到了这个错误:
The ViewData item that has the key 'OccupationId' is of type
'System.Int32' but must be of type 'IEnumerable'.
删除 CkEditor
解决了这个错误,但我确实需要它,相关代码(从视图中)
<div class="form-group">
@Html.LabelFor(model => model.rev.ReviewBody, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.rev.ReviewBody, new { htmlAttributes = new { @class = "form-control", @id = "RevBEditor" } })
@Html.ValidationMessageFor(model => model.rev.ReviewBody, "", new { @class = "text-danger" })
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.sub.Occupation.OccupationDecription, "Occupation", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("OccupationId", null, htmlAttributes: new { @class = "" })
@Html.ValidationMessageFor(model => model.OccupationId, "", new { @class = "text-danger" })
</div>
</div><script src="~/Scripts/ckeditor/ckeditor.js"></script>
<script type="text/javascript"> CKEDITOR.replace('RevBEditor'); </script>
这不是因为 CKEditor,而是因为您没有提供要下拉的数据源
我有一个工作正常的下拉列表,但是当我将 CKEditor
(ckeditor-standard 4.5.7)添加到 handel EditorFor
助手时,我收到了这个错误:
The ViewData item that has the key 'OccupationId' is of type 'System.Int32' but must be of type 'IEnumerable'.
删除 CkEditor
解决了这个错误,但我确实需要它,相关代码(从视图中)
<div class="form-group">
@Html.LabelFor(model => model.rev.ReviewBody, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.rev.ReviewBody, new { htmlAttributes = new { @class = "form-control", @id = "RevBEditor" } })
@Html.ValidationMessageFor(model => model.rev.ReviewBody, "", new { @class = "text-danger" })
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.sub.Occupation.OccupationDecription, "Occupation", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("OccupationId", null, htmlAttributes: new { @class = "" })
@Html.ValidationMessageFor(model => model.OccupationId, "", new { @class = "text-danger" })
</div>
</div><script src="~/Scripts/ckeditor/ckeditor.js"></script>
<script type="text/javascript"> CKEDITOR.replace('RevBEditor'); </script>
这不是因为 CKEditor,而是因为您没有提供要下拉的数据源