こんにちは、mvc5 でドロップダウン リストを作成するのに問題があります。これは私のモデルにあるものです。
public string CountryCode { get; set; }
public LocationChecker()
{
PopulateCountryCodes();
}
public IEnumerable<SelectListItem> CountryCodes { get; set; }
private void PopulateCountryCodes()
{
CountryCodes = new List<SelectListItem>();
CountryCodes.Add (new SelectListItem {Value = "1", Text =“UK”});
CountryCodes.Add (new SelectListItem {Value = "2", Text =“GB”});
CountryCodes.Add (new SelectListItem {Value = "3", Text =“IRL”});
}
これが私の見解です:
<h4>Countries</h4>
add a drop down list
@Html.DropDownListFor(m => m.CountryCode, Model.CountryCodes)
</div>
CountryCodes.Add の ADD は赤で解決できません。また、UK、GB、IRL の直前に「式が必要です」というエラーがあります。
助けていただければ幸いです。mvc5 btwを使用するのはこれが初めてです。
ありがとう
ナビ