Html.DropDownList Selected Value Not Working (Using Constructor with IEnumerable)

后端 未结 8 2063
盖世英雄少女心
盖世英雄少女心 2021-02-18 19:02

I have an issue where the selected value is not working for the Html.DropDownList helper method. See below:

This is My Controller:

public ActionResult Ed         


        
8条回答
  •  感情败类
    2021-02-18 19:03

    @Html.DropDownList("NewsItemId",ViewBag.NewsItemId as SelectList, string.Empty,
        new { @class = "form-control" })
    

    change to

    @Html.DropDownList("NewsItemId", ViewBag.NewsItemIdList as SelectList, string.Empty, 
        new { @class = "form-control" })
    

    ViewBag.NewsItemIdList name changed. also change in controller.

提交回复
热议问题