DataBinding: 'System.Web.Mvc.SelectListItem' does not contain a property with the name 'CategoryTypeID'

后端 未结 2 979
渐次进展
渐次进展 2021-01-04 03:42

I am using MVC. I want to pass the category data I entered from my view and passed to my Post/ Createcontroller, but it\'s not\'s letting me pass my categoryTypeID that I ha

2条回答
  •  别那么骄傲
    2021-01-04 04:30

    You are defining your SelectList twice, in your controller as well as in your view.

    Keep the view clean. Just the following would be enough in your case: @Html.DropDownListFor(model => model.CategoryTypeID, (SelectList)ViewBag.CategoryTypes)

    I have to admit that DropDownListFor is quite confusing in the beginning :)

提交回复
热议问题