EnumHelper.GetSelectList Method

Definition

Overloads

GetSelectList(Type)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given type.

GetSelectList(ModelMetadata)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata.

GetSelectList(Type, Enum)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given type. Also ensures the value will round-trip even if it does not match a defined constant and sets the Selected property to true for one element in the returned list -- matching the value.

GetSelectList(ModelMetadata, Enum)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata. Also ensures the value will round-trip even if it does not match a defined constant and sets the Selected property to true for one element in the returned list -- matching the value.

GetSelectList(Type)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given type.

public static System.Collections.Generic.IList<System.Web.Mvc.SelectListItem> GetSelectList (Type type);
static member GetSelectList : Type -> System.Collections.Generic.IList<System.Web.Mvc.SelectListItem>
Public Shared Function GetSelectList (type As Type) As IList(Of SelectListItem)

Parameters

type
Type

The type to evaluate.

Returns

A list for the given type.

Applies to

GetSelectList(ModelMetadata)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata.

public static System.Collections.Generic.IList<System.Web.Mvc.SelectListItem> GetSelectList (System.Web.Mvc.ModelMetadata metadata);
static member GetSelectList : System.Web.Mvc.ModelMetadata -> System.Collections.Generic.IList<System.Web.Mvc.SelectListItem>
Public Shared Function GetSelectList (metadata As ModelMetadata) As IList(Of SelectListItem)

Parameters

metadata
ModelMetadata

The model metadata to evaluate.

Returns

A list for the given metadata.

Applies to

GetSelectList(Type, Enum)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given type. Also ensures the value will round-trip even if it does not match a defined constant and sets the Selected property to true for one element in the returned list -- matching the value.

public static System.Collections.Generic.IList<System.Web.Mvc.SelectListItem> GetSelectList (Type type, Enum value);
static member GetSelectList : Type * Enum -> System.Collections.Generic.IList<System.Web.Mvc.SelectListItem>
Public Shared Function GetSelectList (type As Type, value As Enum) As IList(Of SelectListItem)

Parameters

type
Type

The type to evaluate.

value
Enum

The value from type to select.

Returns

A list for the given type, possibly extended to include an unrecognized value.

Applies to

GetSelectList(ModelMetadata, Enum)

Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata. Also ensures the value will round-trip even if it does not match a defined constant and sets the Selected property to true for one element in the returned list -- matching the value.

public static System.Collections.Generic.IList<System.Web.Mvc.SelectListItem> GetSelectList (System.Web.Mvc.ModelMetadata metadata, Enum value);
static member GetSelectList : System.Web.Mvc.ModelMetadata * Enum -> System.Collections.Generic.IList<System.Web.Mvc.SelectListItem>
Public Shared Function GetSelectList (metadata As ModelMetadata, value As Enum) As IList(Of SelectListItem)

Parameters

metadata
ModelMetadata

The metadata to evaluate.

value
Enum

Value from the type of metadata to select.

Returns

A list for the given metadata, possibly extended to include an unrecognized value.

Applies to