anyone came up with simple solutions?
question: Given the two model classes with a relationship of one-to-many, how can i design a single create for these..
I don't know how clever MVC's binding is since I use my own binding so I don't know whether it can do the binding to models for you.
What you can do is to number all the inputs for each line. So Product1
, 'Amount1`, etc. For each new line (say there is an 'Add Detail' button) you create a new set of inputs with the next available number.
When you parse the Request.Form
you simply ask for each line until you cannot find one --- then you know you are done.
HTH
The short answer is really "it depends" :) The question you need to ask first (and it has nothing to do with MVC) is the following: when do you want to commit user entries? I can think of several options:
Additionally, you need to answer the same question about order details. Do you want to submit every row, or allow the user to create multiple rows (through some "Add Row" button and JavaScript code behind it) and then submit a set of rows.
Once you decide which way you want to go - it will be easier to design the form. If you run into problems - come back; I am sure you will get plenty of help!
God luck