asp.net mvc 4 - DisplayForModel is not working mvc4 -
my controller:
public viewresult index() { return view("normal", postaladdressrepo.all() ienumerable<postaladdress>); }
normal.cshtml
@model ienumerable<object> @html.displayformodel()
it not displaying records, instead displaying below:
system.data.entity.dynamicproxies.contactmechanism_4e4bc83827d1fe8c7cd34454310ef12db90e894128f3024aeb8c7e9bf8843d2asystem.data.entity.dynamicproxies.contactmechanism_4e4bc83827d1fe8c7cd34454310ef12db90e894128f3024aeb8c7e9bf8843d2a
if use below, working fine:
@model ienumerable<object> @foreach (object obj in model) { @html.displayfor(m => obj) }
not sure doing wrong displayformodel().
can advise?
try eagerly loading model before passing view:
public viewresult index() { var model = postaladdressrepo.all() ienumerable<postaladdress>; return view("normal", model.tolist()); }
also make view typed same type model:
@model ienumerable<postaladdress> @html.displayformodel()
Comments
Post a Comment