0
リストをグリッドに表示するビューに渡しています。グリッドの下には、ユーザーがグリッドに新しい値を送信するためのフォームがあります。コントローラが呼び出されたとき、モデルは常に空であるように見えますが、私は何が間違っているのか、まったく違う方法でこれをやっていなければならないのか分かりません。複数のフォームを持つMVCモデル
@model IList<PSIApp.Models.PSM_StationTimetableView>
@using (Html.BeginForm())
{
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse3">Hourly Update ▼</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse in" style="width:100%; margin-left:0%; margin-right:50px;">
<div class="mainformCollapse" style="width:100%; margin-left:0%; margin-right:50px;">
<p class="group-header">Hourly Update</p>
<div class="form-group row">
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">BP Issued</label>
<div class="col-xs-3">
@Html.MyTextBoxFor(p => p[0].PSM_StationBPData.BPIssued, new { @class = "generalformbox" }, false)
</div>
<label for="example-text-input" class="col-xs-3 col-form-label " id="formLabelId">BP Cancelled/Spoilt</label>
<div class="col-xs-3">
@Html.TextBoxFor(p => p[0].PSM_StationBPData.BPSpoilt, new { @class = "generalformbox" })
</div>
</div>
<div class="form-group row">
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">AV Issued</label>
<div class="col-xs-3">
@Html.TextBoxFor(p => p[0].PSM_StationBPData.PostalReceived, new { @class = "generalformbox" })
</div>
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">Tendered Issued</label>
<div class="col-xs-3">
@Html.TextBoxFor(p => p[0].PSM_StationBPData.BPTendered, new { @class = "generalformbox" })
</div>
</div>
<input type="submit" value="Submit Hourly Update" class="standardsubmitbt" />
</div>
</div>
</div>
</div>
}
コントローラ
public ActionResult POControl(Models.PSM_StationBPData model)
{
return RedirectToAction("POControl");
}
あなたのブラウザやフィドラーのようなツールから投稿された値を確認してみてください – mahlatse
あなたの生成フォームはインデクサーで制御されます。つまり、コントローラメソッドが 'public ActionResult POControl(List model)'である必要があります。コードは意味をなさない。編集する 'PSM_StationTimetableView'の各プロパティのプロパティと、グリッドに表示されるコレクションのIEnumerable StationTimetableList'プロパティを含むビューモデルが必要です –