@Html.EditorFor
requires a strongly-typed model. It cannot be used with data from the ViewBag
.
If you must use ViewBag
to pass data to the view, use @Html.TextFor(...)
instead to manually setup the input field.
However, I recommend you use a strongly-typed model.
Edit:
Model:
public class MyModel
{
public TABLE_CODES Keys { get; set; }
}
Controller:
var model = new MyModel();
model.Keys = new TABLE_CODES();
return View(model);
View:
@model MvcApplication1.MyModel
....
@Html.EditorFor(m => m.Keys)