ViewBag と DropDownListFor で少し問題が発生しました。以下のコードは正常に動作していますが、値が 0 の項目を「手動で」追加する必要があります。これを行う方法はありますか?
public ActionResult Create()
{
ViewBag.ParagrafyRodzic = paragrafRepository.All;
return View();
}
@Html.DropDownListFor(model => model.ParagrafID, ((IEnumerable<Projekty03.Models.Paragraf>)ViewBag.ParagrafyRodzic)
.Select(option => new SelectListItem
{
Text = option.ParagrafNazwa.ToString(),
Value = option.ParagrafID.ToString(),
Selected = (Model != null) && (option.ParagrafID == Model.ParagrafParent)
}),Translate.ChooseList)
:) Tx ヘルプ