Select Tag Helper in ASP.NET Core MVC

前端 未结 6 2238
再見小時候
再見小時候 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:06

    My answer below doesn't solve the question but it relates to.

    If someone is using enum instead of a class model, like this example:

    public enum Counter
    {
        [Display(Name = "Number 1")]
        No1 = 1,
        [Display(Name = "Number 2")]
        No2 = 2,
        [Display(Name = "Number 3")]
        No3 = 3
    }
    

    And a property to get the value when submiting:

    public int No { get; set; }
    

    In the razor page, you can use Html.GetEnumSelectList() to get the enum properties.

    
    

    It generates the following HTML:

    
    

提交回复
热议问题