Ich habe das folgende Formular, das Daten in einem mehrdimensionalen Array enthält, das ich an meinen Server senden möchte. Das Problem ist, dass ich nicht in der Lage bin, diese Daten in meinem Controller abzurufen.Kann nicht übermittelte Formulardaten von MVC-Controller lesen
index.html
<form id="my-form" action="/Home/TestingMethod" method="post">
<table id="people" class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Owns Item</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Danny</td>
<td class="items">
<select name="PersonList[1]Item[]" class="form-control">
<option value=""></option>
<option value="Keys">Keys</option>
<option value="Phone">Phone</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
MyModel
public class MyModel
{
public List<int> PersonList { get; set; }
}
Homecontroller
[HttpPost]
public JsonResult TestingMethod(MyModel model)
{
List<int> list_of_people = model.PersonList;
return Json("I am the server, I got your data.");
}
Das Problem ist, dass 0.123.enthält 0 Elemente.
Formulardaten vorgelegt
PersonList[1]Item[]:Phone
bezogen werden: how to access Javascript multidimensional array in MVC controller
Ihre 'PersonList' ist eine Liste von int, aber der Wert Ihrer Auswahl ist eine Zeichenkette? – Alex
die 'Person' in meiner Form liefert eine int 1.' Person [1] ' –
Was ist mit allen Down-Stimmen? –