HTML の結果は次のようになります。
<input type="text" name="Code" value=""/>
...
<table>
<thead>
<tr>
<th>#</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><input type="hidden" name="InvoiceItems[0].Name" value="InvoiceItem1"/></td>
</tr>
<tr>
<td>2</td>
<td><input type="hidden" name="InvoiceItems[1].Name" value="InvoiceItem2"/></td>
</tr>
<tr>
<td>3</td>
<td><input type="hidden" name="InvoiceItems[2].Name" value="InvoiceItem3"/></td>
</tr>
</tbody>
</table>
<button type="submit">Submit</button>
</form>
このようにして、プレーンフォーム送信または ajax を使用できます
// assuming you have only one form. otherwise use more specific selector
var $form = $("form");
var data = $form.serializeArray();
var url = $form.attr("href") || document.URL;
$.post(url, data, yourCallbackFunction);
残りは ModelBinder によって行われます。InvoiceItems
重要な部分は、インデックスを維持することです。それらは 0 から始まり、連続している必要があります。つまり、0、1、2、3 などです。いくつかのインデックスをスキップすると、modelbinder はインデックスが壊れているリストのバインドを終了します。