asp.net - MVC 5 Complex View Model binding is not working -
public class createprojemodel { public proje proje { get; set; } public list<geometrymodel> geometrylist { get; set; } public createprojemodel() { proje = new proje(); geometrylist = new list<geometrymodel>(); } } public class geometrymodel { public list<pointmodel> pointlist { get; set; } public geometrymodel() { pointlist = new list<pointmodel>(); } } public class pointmodel { public int x { get; set; } public int y { get; set; } } public class proje : entitybase { public int firmaid { get; set; } public int ilid { get; set; } public int? ilceid { get; set; } public int planturid { get; set; } public int etudturid { get; set; } public int etudamacid { get; set; } public int dilimid { get; set; } public string aciklama { get; set; } public virtual firma firma { get; set; } public virtual il il { get; set; } public virtual ilce ilce { get; set; } public virtual plantur plantur { get; set; } public virtual etudtur etudtur { get; set; } public virtual etudamac etudamac { get; set; } public virtual dilim dilim { get; set; } }
i have complex model named createprojemodel. i'm using 'for' loop collection properties , binding below:
@html.textboxfor(m => m.geometrylist[i].pointlist[j].x)
action below:
[httppost] public async task<actionresult> create(createprojemodel proje) { //todo return view(proje); }
posted data below:
when comes action, geometrylist empty , proje's properties not set post values. doing wrong?
your problem createprojemodel
model has property named proje
, parameter of create()
method named proje
. need change method signature (say)
public async task<actionresult> create(createprojemodel model)
where parameter name not same nae of 1 of properties
Comments
Post a Comment