How to use a ViewBag to create a dropdownlist?

后端 未结 7 2229
失恋的感觉
失恋的感觉 2020-12-01 07:35

Controller:

public ActionResult Filter()
{
    ViewBag.Accounts = BusinessLayer.AccountManager.Instance.getUserAccounts(HttpContext.User.Identity.Name);
             


        
相关标签:
7条回答
  • 2020-12-01 08:12

    hope it will work

     @Html.DropDownList("accountid", (IEnumerable<SelectListItem>)ViewBag.Accounts, String.Empty, new { @class ="extra-class" })
    

    Here String.Empty will be the empty as a default selector.

    0 讨论(0)
提交回复
热议问题