トランザクション数が動的なインポート ページがあります。トランザクションごとに、いくつかのプレーン テキスト データ ラベルと 1 つの DropDownList (Categories) があります。カテゴリ モデルを additionalViewData として EditorTemplate に渡すことにより、このCategory
DropDownList に ViewModel ( ) からのデータを入力しようとしています。Categories
以下の例を使用すると、EditorTemplate ページに次のエラーが表示されます。 .Linq.Expressions.Expression>, System.Collections.Generic.IEnumerable)' は、使用法から推測できません。型引数を明示的に指定してみてください。
これを修正する方法についてのアイデアはありますか?
ビューモデル:
public class ImportViewModel
{
public List<AbnAmroTransaction> AbnAmroTransactions { get; set; }
public IEnumerable<SelectListItem> Categories { get; set; }
}
モデル:
public class AbnAmroTransaction
{
public string Currency { get; set; }
public int DateTime { get; set; }
public string Description { get; set; }
public int CategoryId { get; set; }
}
形:
@using (Html.BeginForm("ImportPreview", "Home", FormMethod.Post))
{
<table>
@Html.EditorFor(m => m.AbnAmroTransactions, new { Categories = Model.Categories });
</table>
<input id="btnSave" type="submit" value="Save data" />
}
エディター テンプレート:
<tr>
<td style="width: 80px;">
@Html.Raw(CurrencyHelper.GetHtmlCurrency(Model.Currency, Model.Amount))
</td>
<td>@Model.DateTime</td>
<td>@Model.Description</td>
<td>@Html.DropDownListFor(Model.CategoryId, ViewData["Categories"])</td>
</tr>