0

列挙型を MVC のドロップダウンにバインドして、投稿後にモデルを有効にするにはどうすればよいですか? コンバーターなどが必要かどうかわからないので、コードを提供します。推奨される解決策は何ですか? (以下のコードは ModelError を引き起こします)

列挙型:

public enum TimePlan
{   Routine = 0,
    Single = 1 }

モデル:

 public TimePlan TheTimePlan { get; set; }

 public SelectListItem[] TimeList { get; set; }

コントローラー:

    [HttpPost]
    public virtual ActionResult Education(EducationViewModel EducationModelInfo)
    {
        if (ModelState.IsValid)
        { ...
    } }

ビューバインディング:

@Html.DropDownListFor(m => m.CourseTimePlan, Model.TimeList, "Please select the time plan") 
4

1 に答える 1