ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Create Incoming Properties are all Null
Title:
B
I
{code}
?
My Create.cshtml view uses the Project_IDsVM ViewModel like so: @model PWP_V2.ViewModels.Grids.Project_IDsVM And my Create function is in my controller: [HttpPost] public ActionResult Create(Project_IDsVM input) { if (ModelState.IsValid) { Mapper.CreateMap<Project_IDsVM, Project_IDs>(); var item = Mapper.Map<Project_IDsVM, Project_IDs>(input); db.Project_IDs.Add(input); db.SaveChanges(); return Json(new { Content = this.RenderView("~/Views/Grids/Project_IDsVM/_List.cshtml", new[] { item }) }); } return View("Create", input); } When I put a breakpoint, the input parameter has null for all of the properties. What's peculiar is that if I change the parameter type to Project_IDs (the model that the ViewModel is based off of), the properties are populated as they should be. Any idea why this is happening? EDIT 1: [HttpPost] public ActionResult Create(Project_IDs input) { ... }
Save Changes
Cancel
rsnider19
asked at 24 Feb 2014
rebuild all, view source in the html, make sure the inputs in the html have name attributes equal to the properties
at 24 Feb 2014
Omu
The values are there if I have the parameter as Project_IDs (See EDIT 1 above). It seems as if the Create function is expecting an object of type Project_IDs instead of type Project_IDsVM.
at 24 Feb 2014
rsnider19
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK