Getting error on POST with Entity Framework - Value cannot be null. Parameter name: source

前端 未结 2 612
闹比i
闹比i 2021-01-24 05:20

EDIT - as requested, this is the view...

--start edit

@model salesWebTest.viewModel.vwbooking

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html         


        
2条回答
  •  梦毁少年i
    2021-01-24 06:00

    The issue appears to be the way the editor is setup. I believe that this is causing the model to not properly bind on submit

    @Html.EditorFor(m => item.contact_Name)
    

    If you were to inspect the name attribute of the element generated by this helper, you will more than likely see that it reads

    
    

    for every one of these. It may even just say name="contact_Name".

    This is a severe drawback of the framework and the workarounds for it are usually to make a whole custom helper or to use a front end solution to fix the names.

    The name must match exactly to the model. What it should be for your values is

    
    
    etc..
    

    and so I would suggest figuring out a way that works with your current project to make sure that those names get properly set.

提交回复
热议问题