Error with DropDownList when CKEditor is also in use on page [duplicate]

怎甘沉沦 提交于 2019-12-25 17:06:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!