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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With