Share via


HtmlHelper.GetEnumSelectList Method

Definition

Overloads

GetEnumSelectList(ModelMetadata)

Returns a select list for the given metadata.

GetEnumSelectList(Type)

Returns a select list for the given enumType.

GetEnumSelectList<TEnum>()

Returns a select list for the given TEnum.

GetEnumSelectList(ModelMetadata)

Source:
HtmlHelper.cs
Source:
HtmlHelper.cs
Source:
HtmlHelper.cs

Returns a select list for the given metadata.

protected virtual System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> GetEnumSelectList(Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata metadata);

Parameters

metadata
ModelMetadata

ModelMetadata to generate a select list for.

Returns

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

Exceptions

Thrown if metadata's ModelType is not an Enum or if it has a FlagsAttribute.

Applies to

GetEnumSelectList(Type)

Source:
HtmlHelper.cs
Source:
HtmlHelper.cs
Source:
HtmlHelper.cs

Returns a select list for the given enumType.

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.

Implements

Applies to

GetEnumSelectList<TEnum>()

Source:
HtmlHelper.cs
Source:
HtmlHelper.cs
Source:
HtmlHelper.cs

Returns a select list for the given TEnum.

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.

Implements

Applies to