How to use Html.EditorFor with a type List<object>

102 views Asked by At

I am creating a form that a list of Education and work experiences but i am getting an error "Cannot convert lambda expression to type 'Education' because it is not a delegate type " when trying this

@model Resume
@Html.EditorFor(m => m.Fullname, new { htmlAttributes = new { @class = "form-control", placeholder = "Your Full Name" } })

my resume object has a

public List<Education> Educations { get; set; }

also i have a section for Education with a button "Add Another" which duplicates that section thats why it is a list

1

There are 1 answers

1
Gabriel Rodrigues On

Do you want to create a list form?

If yes you can use @Html.DropDownList with ViewBag:

Controller:

ViewBag.Educations = EducationsList;

View: @Html.DropDownList("Educations", null, "", htmlAttributes: new { @class = "form-control"})