Select Tag Helper in ASP.NET Core MVC

前端 未结 6 2206
再見小時候
再見小時候 2020-11-22 04:35

I need some help with the select tag helper in ASP.NET Core.

I have a list of employees that I\'m trying to bind to a select tag helper. My employees are in a

6条回答
  •  醉梦人生
    2020-11-22 05:18

    In Get:

    public IActionResult Create()
    {
        ViewData["Tags"] = new SelectList(_context.Tags, "Id", "Name");
        return View();
    }
    

    In Post:

    var selectedIds= Request.Form["Tags"];
    

    In View :

    
    
    

提交回复
热议问题