in an ASP.NET-MVC 5 application I have the following models
class Employee {
int EmployeeID {get;set;}
string FirstName {get;set;}
List<OfficeLocations> OfficeLocations {get;set;}
}
class OfficeLocations {
int OfficeLocationsID {get;set;}
//foreign key
int EmployeeID {get;set;}
string Value1 {get;set;}
string Value2 {get;set;}
}
I have an edit view for modifying or ADDING different office locations that an employee could belong to. It looks something like this:
@model List<Project.Models.OfficeLocations>
@for (int i = 0; i < Model.Count; i++) {
@Html.EditorFor(m => m[i].CitLocation, new { htmlAttributes = new { @class = "my_editor" } })
@Html.HiddenFor(m => m[i].OfficeLocationsID)
@Html.HiddenFor(m => m[i].EmployeeID)
}
//extra editor box for adding a new value
@Html.Editorfor(??????.Value)
I'm a little confused as to how to add new entries to my model (list) in the database table. What do I put in the parameter for the extra Editorfor box (where all the ???? are)
also, what would the controller action method look like?