1
以下のフィールドをポストバックすると、このエラーが発生します。「System.Decimal」タイプのオブジェクトを「System.String」とタイプすることができません。小数点を含むエディタフィールドをポストバックする際のエラー
<div class="editor-label">
@Html.LabelFor(model => model.Donation.Amount)
</div>
<div class="editor-field">
@Html.TextBox("Amount", string.Format("{0:f2}", Model.Donation.Amount))
<!-- @Html.EditorFor(model => model.Donation.Amount) -->
@Html.ValidationMessageFor(model => model.Donation.Amount)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Pledge.PledgeTotal)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Pledge.PledgeTotal)
@Html.ValidationMessageFor(model => model.Pledge.PledgeTotal)
</div>
どちらのモデルでは小数点以下の特性がある...それは、文字列として戻って投稿しようとしている:
フィールドフォームの一部として?その後、私はそれを小数点に戻してポストバックする方法はありますか?何かご意見は?ありがとう。あなたのビューモデルでは
:
は、我々はあなたのアクションメソッドを見ることができますか? – Shyju
私の間違い...下のコメントを見る – 1Canuck16