私は別のプロジェクトを引き継ぎ、この1つの問題を除いて他のすべてを修正しました。私は以前にこれを見たことがあると思いますが、私の人生の間、解決策が何であったかを思い出すことができません。
.sparkビューのテーブルは次のようになります。次に、getJSON()を使用するJQueryスクリプトが呼び出され、最初にすべての行がクリアされてからtbodyにデータが入力され、すべての行と列が作成され、各行の最初の列にチェックボックスが追加されます。各チェックボックスは「testitem」と呼ばれます。 '。
<form id='new_test_items' name='new_test_items' method='post' action='${Url.Action("AddTestItems", new { id = Model.TestID })}'>
<table id='component_list' name='component_list' class='component_list_table striped_table' cellpadding='0' border='0' cellspacing='0'>
<thead>
<tr>
<th> </th>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th>Column5</th>
<th>Column6</th>
<th>Column7</th>
<th>Column8</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</form>
フォームを送信するための.clickイベントハンドラーもあります。
$('#add_selected').click(function() {
var $items = $('#component_list input:checkbox:checked');
// If none checked, alert
if ($items.length == 0) {
alert('No items have been selected.');
return false;
}
else {
$('#new_test_items').submit();
}
});
フォームはコントローラーアクションに送信され、チェックボックスはフォームコレクションに戻されると想定しました。
public ActionResult AddTestItems(int id, FormCollection coll)
{
Dictionary<string, ValueProviderResult> vals = coll.ToValueProvider() as Dictionary<string, ValueProviderResult>;
// vals is null here
}
valsが作成されると、nullとして返されます。したがって、formcollectionにデータが含まれていないか、私が知らない辞書の作成に問題があります。
どんな助けでも大歓迎です。
ありがとう!