次のようなドロップダウンリストがあります。
@Html.DropDownList("DeliveryOptions",
(IEnumerable<SelectListItem>)ViewData["DeliveryOptions"])
これは、次のようにコントローラ アクションからデータを取得します。
var options = context.DeliveryTypes.Where(x => x.EnquiryID == enqId);
ViewData["DeliveryOptions"] = new SelectList(options, "DeliveryTypeId",
"CODE" + " - " + "DeliveryPrice");
ドロップダウンCODE + DeliveryPrice
リストのテキスト フィールドに「TNTAM - 17.54」のように表示したいのですが、次のエラーが表示されます。
DataBinding: 'MyApp.Models.DeliveryTypes' does not contain a property
with the name 'CODE - DeliveryPrice'.
私の DeliveryType モデルは次のようになります。
[Key]
public int DeliveryTypeId { get; set; }
public string CODE { get; set; }
public decimal DeliveryPrice { get; set; }