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

后端 未结 8 2058
盖世英雄少女心
盖世英雄少女心 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:27

    change viewbag property name to other then model variable name used on page.

    0 讨论(0)
  • 2021-02-18 19:28

    You should change the very name of the field of your DropDownList:

    @Html.DropDownList("Some_Name_that_does_not_exist_in_model", ViewBag.NewsItemId as SelectList, string.Empty, new { @class = "form-control" })
    
    0 讨论(0)
提交回复
热议问题