input
タイプの自動的に生成されたボックスを含むビューがありますtext
。[Email Results] ボタンをクリックすると、コードによって CalculatedResults コントローラー内の EmailResults アクションに移動します。ここまでは順調ですね。しかし、EmailResults アクションのパラメーターとして FormCollection を使用しているにもかかわらず、null として送信されており、その理由がわかりません。フォームからテキストボックスをキャプチャできるようにする必要があります-助けてください!!. 以下の View コードでは、生成されたテキスト ボックスが半分過ぎたところにあります。
マイ ビュー コード
@using (Html.BeginForm("EmailResults", "CalculatedResults", FormMethod.Post, new { data_ajax = "false" }))
{
<table>
<thead>
<tr>
<td>Ingredient</td>
<td>Qty (gm)</td>
</tr>
</thead>
@foreach (var i in Model)
{
if (Convert.ToDecimal(i.Qty) < 0)
{
<tr>
<td style="border: 1px solid red; color: red;">@i.Ingredient</td>
<td style="border: 1px solid red; color: red;">@i.Qty</td>
</tr>
}
else if (Convert.ToDecimal(i.Qty) == 0m)
{
continue;
}
else
{
if (i.Ingredient.Contains("Active"))
{
<tr>
<td>@i.Ingredient<br />
<input type="text" name="actives" /></td>
<td>@i.Qty</td>
</tr>
}
else
{
<tr>
<td>@i.Ingredient</td>
<td>@i.Qty</td>
</tr>
}
}
}
</table>
}
<div style="float: left">
@Html.ActionLink("Email Results", "EmailResults", "CalculatedResults", new { crpk = @ViewBag.crpk }, new { data_icon = "arrow-r", data_role = "button" })
</div>
私のコントローラーコード
public ViewResult EmailResults(int crpk, FormCollection collection)
{
CapWorxQuikCapContext context = new CapWorxQuikCapContext();
//List<string> variables = new List<string>();
//foreach (var item in Request.Form)
//{
// variables.Add(item.ToString());
//}
CalculatedResults cr = (from i in context.CalculatedResults where i.Pk == crpk select i).SingleOrDefault();
Helpers.Email.EmailResults(cr);
return View();
}
スクリーンショットは次のとおりです。