问题
I have a dropdownlist that is working just fine, but when I have add a CKEditor
(ckeditor-standard 4.5.7) to handel EditorFor
helper I'm getting this error:
The ViewData item that has the key 'OccupationId' is of type 'System.Int32' but must be of type 'IEnumerable'.
Removing the CkEditor
solve this error but I do need it, relevant code (from view)
<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>
回答1:
That's not because of CKEditor, that is happening because you did not give a data source to drop down
来源:https://stackoverflow.com/questions/35892025/error-with-dropdownlist-when-ckeditor-is-also-in-use-on-page