There is no ViewData item of type 'IEnumerable' that has the key country

后端 未结 11 2197
鱼传尺愫
鱼传尺愫 2020-12-03 07:52

While binding dropdown in MVC, I always get this error: There is no ViewData item of type \'IEnumerable\' that has the key country.

<
11条回答
  •  Happy的楠姐
    2020-12-03 08:18

    Replace "country" with "countrydrop" in your view like this...

    @Html.DropDownList("countrydrop", (IEnumerable)ViewBag.countrydrop,"Select country")
    

提交回复
热议问题