ASP.NET Core MVC Web Appで引用フォームを作成しています。私は引用符で動的に多くのアイテムを格納するために必要な見積書のプロパティに加え一覧QuoteItemsが含まれていることQuoteVMを持っている:ASP.NET Core MVCビューでリストの入力から不正な値が表示される
public class QuoteVM
{
public string Status { get; set; }
public QuoteItemVM NewQuoteItem { get; set; }
#region QuoteProperties
// Not relevant
#endregion
#region Company
// Not relevant
#endregion
#region Client
// Not relevant
#endregion
public List<QuoteItemVM> QuoteItems { get; set; }
public List<string> WorkItems = new List<string>();
public List<string> UnitList = new List<string>
{
"lm",
"fm",
"dag",
"heild",
"stk",
"klst"
};
}
私の見解では、私は時に引用項目を追加するためにオートコンプリートで入力フィールドを追加しました見積もり項目が選択されている場合、私のフォームはコントローラのPOSTアクションにVMをポストし、新しい見積もり項目をQuoteItemsリストに追加してQuoteVMを再度返します。リストは見積もり項目番号プロパティで並べ替えられてビューに送信されます。デバッグすると、リストがビューに正しく送信されていることがわかります。このビューは、QuoteItemsリストを段落に書き込むことによっても検証できます。ここで私は期待通りに働いている私の引用、すべての4つの項目を追加しました: Values are still correct
今、私たちは最終的に私は私のテーブルに私が持っているよりも低い数字を持っている引用項目を追加するときということです問題に来ます関連している私の見解の一部を Where things start to go south...
:それは、テーブルをレンダリングするとき、間違った値を示す開始するが、コントローラが正しくリストを返すので、リストが正しいだろう
@{ // display values to check if they're correct
foreach (var item in Model.QuoteItems)
{
<p>@item.Number - @item.Description - @item.Unit</p>
}
}
<tbody>
@{ // the goal is to display them correctly here
for (int i = 0; i < Model.QuoteItems.Count(); i++)
{
<tr>
<td><input type="checkbox" class="i-checks" name="input[]"></td>
<td><input asp-for="QuoteItems[i].Number" class="form-control text-center input-sm" /></td>
<td><input asp-for="QuoteItems[i].Description" placeholder="Verkþáttur" class="form-control input-sm" /></td>
<td><input asp-for="QuoteItems[i].Quantity" placeholder="Magn" class="form-control text-center input-sm jsQuantity calculate" /></td>
<td><input asp-for="QuoteItems[i].Unit" placeholder="Eining" class="form-control text-center units input-sm" /></td>
<td><input asp-for="QuoteItems[i].UnitPrice" placeholder="Einingarverð" class="form-control text-center input-sm jsUnitPrice calculate" /></td>
<td><input asp-for="QuoteItems[i].TotalPrice" class="form-control text-center input-sm jsTotalPrice" /></td>
<td><input asp-for="QuoteItems[i].TotalPriceVAT" class="form-control text-center input-sm jsTotalPriceVAT" /></td>
</tr>
}
}
</tbody>
は、誰も実行を持っています同様の問題や知り合いに何が原因でしょうか?