c# - Post Multiple List of objects in MVC -


Can I submit a form that has 2 set objects, my model looks like

   

How do I submit ModelToSubmit for the controller? Any remedy? {ModelToSubmit

Name of MVC HTML elements The feature uses the Named attribute in the following format:

   & Lt; Input type = 'text' name = 'item [0].' Value '/ & gt; . . . & Lt; Input type = 'text' name = 'item [n]. Id' /> & Lt; Input type = 'text' name = 'item [n] .name' / & gt; & Lt; Input type = 'text' name = 'item [n].' Value '/ & gt;   

and for transItems

  & lt; Input type = 'text' name = 'transItems [0] .Id' /> & Lt; Input type = 'text' name = 'trans itims [0] .name' /> & Lt; Input type = 'text' name = 'transitem [0] .Price' /> . . . & Lt; Input type = 'text' name = 'trans itims [m]. Id' /> & Lt; Input type = 'text' name = 'trans itims [m] .name' /> & Lt; Input type = 'text' name = 'trans itims [m] .pris' />   

So you need to make sure that your HTML control and transmes related to the item have this format for the name attribute.

Hope that helps.

Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

c++ - Redefined variable in the other module -