0
ID를 설정할 수있는 기능이있는 드롭 다운 목록을 만들려고합니다. 동일한 뷰 백에서 2 개가 있으므로. 지금 MVC 드롭 다운 목록에 문제가있어 설정하는 방법이 확실하지 않습니다.
@Html.DropDownList("startTimes", (SelectList)ViewBag.times, new { @class = "date" })
@Html.DropDownList("endTimes", (SelectList)ViewBag.times, new { @class = "date" })
같은, 나는
ViewBag.times = getTimeList();
private List<SelectListItem> getTimeList() { List<SelectListItem> times = new List<SelectListItem>(); for (int Minutes = 60; Minutes < 770; Minutes += 30) { TimeSpan TS = TimeSpan.FromMinutes(Minutes); String TSString = String.Format("{0:00}:{1:00}", TS.Hours, TS.Minutes); SelectListItem item = new SelectListItem(); item.Text = TSString; item.Value = TS.Minutes.ToString(); times.Add(item); } return times; }
해야하지만 오류가 점점 오전 : 'System.Web.Mvc.SelectList'에 유형 'System.Collections.Generic.List을'변환 할 수 없습니다 오류가 언급 한 바와 같이 여기
감사합니다. 이 훌륭한 작품 –