c# - adding new values to database from view whose model is a list -



c# - adding new values to database from view whose model is a list -

in asp.net-mvc 5 application have next 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 edit view modifying or adding different office locations employee belong to. looks this:

@model list<project.models.officelocations> @for (int = 0; < 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 adding new value @html.editorfor(??????.value)

i'm little confused how add together new entries model (list) in database table. set in parameter editorfor box (where ???? are)

also, controller action method like?

change viewmodel have officelocation , list of officelocation... can add together non list officelocation object in editor box... or can retain viemodel , manually create model using jquery , pass using ajax jquery...

c# asp.net asp.net-mvc entity-framework

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -