Binding DropDownList into MVC View

前端 未结 3 1947
悲&欢浪女
悲&欢浪女 2020-12-09 06:27

Reading from here: ASP.NET MVC

Action SelectCategory has been created inside controller -

 public ActionResult SelectCategory() {

              


        
3条回答
  •  不思量自难忘°
    2020-12-09 06:45

    while binding you list to DropDown you need to type cast it to IEnumerable as you use @Html.DropDown control which is not strongly type with Model

    In View

    @Html.DropDownList("MovieType",(IEnumerable)ViewBag.MovieType) 
    

    and for another way if you bind IdList then

    @Html.DropDownList("IdList",(IEnumerable)ViewBag.IdList)
    

提交回复
热议问题