How to cast in MVC 3 an object from ViewBag to IEnumerable ?
i would like to do soethnig like that:
@Html.DropDownListFor(model => model.CategoryID, @(IEnumerable<SelectListItem>)ViewBag.CategoriesList)
the dropdownlist takes IEnumerable as an argument, but I don't know how to cast it properly. The above code returns an error.
@Html.DropDownListFor(
    model => model.CategoryID, 
    (IEnumerable<SelectListItem>)ViewBag.CategoriesList
)
@Html.DropDownList("categoryId",
            new SelectList(ViewBag.Categories as System.Collections.IEnumerable,
            "categoryId", "categoryName", Model.categoryId))
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论