IHtmlHelper.GetEnumSelectList Method

Definition

Overloads

GetEnumSelectList(Type)

Returns a select list for the given enumType.

GetEnumSelectList<TEnum>()

Returns a select list for the given TEnum.

GetEnumSelectList(Type)

Source:
IHtmlHelper.cs

Returns a select list for the given enumType.

C#
public System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> GetEnumSelectList (Type enumType);

Parameters

enumType
Type

Type to generate a select list for.

Returns

An IEnumerable<T> containing the select list for the given enumType.

Exceptions

Thrown if enumType is not an Enum or if it has a FlagsAttribute.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

GetEnumSelectList<TEnum>()

Source:
IHtmlHelper.cs

Returns a select list for the given TEnum.

C#
public System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> GetEnumSelectList<TEnum> () where TEnum : struct;

Type Parameters

TEnum

Type to generate a select list for.

Returns

An IEnumerable<T> containing the select list for the given TEnum, with a decimal representation of the ordinal as Value and the display name as Text.

Exceptions

Thrown if TEnum is not an Enum or if it has a FlagsAttribute.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0