これは私を夢中にさせています!データベースから値を取得するドロップダウン リストを作成しようとしています。私はMVCが初めてなので、おそらく単純なものですが、わかりません。助けてください!
モデルを見る:
public class LoadInputModel
{
public GeoRegion GeoRegion { get; set; }
public System.Guid Id { get; set; }
public IEnumerable<GeoRegion> Description { get; set; }
}
これが私のコントローラーです:
[HttpPost]
public ActionResult LoadShape(LoadInputModel LoadInputModel)
{
LoadInputModel.Description = db.GeoRegions.Select(a => a);
return View(LoadInputModel);
}
これが私のhtmlヘルパーです:
@Html.DropDownListFor(m => m.Description,Model.Description.Select(c => new SelectListItem { Text = c.Description, Value = c.Id.ToString() }), "-----Select Category----")