EnumHelper.GetSelectList Method
Gets a list SelectListItem objects for the provided values.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
| Name | Description | |
|---|---|---|
![]() ![]() | GetSelectList(ModelMetadata) | Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata. |
![]() ![]() | 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. |
![]() ![]() | 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. |
EnumHelper.GetSelectList Method (ModelMetadata)
Gets a list of SelectListItem objects corresponding to enum constants defined in the given metadata.
Parameters
- metadata
-
Type:
System.Web.Mvc.ModelMetadata
The model metadata to evaluate.
Throws if IsValidForEnumHelper returns false for the given metadata.
EnumHelper.GetSelectList Method (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.
Parameters
- metadata
-
Type:
System.Web.Mvc.ModelMetadata
The metadata to evaluate.
- value
-
Type:
System.Enum
Value from the type of metadata to select.
Return Value
Type: System.Collections.Generic.IList<SelectListItem>A list for the given metadata, possibly extended to include an unrecognized value.
Throws if IsValidForEnumHelper returns false for the given metadata or if a non-null value has a different type than metadata.ModelType.
EnumHelper.GetSelectList Method (Type)
Gets a list of SelectListItem objects corresponding to enum constants defined in the given type.
Parameters
- type
-
Type:
System.Type
The type to evaluate.
Throws if IsValidForEnumHelper returns false for the given type.
EnumHelper.GetSelectList Method (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.
Parameters
- type
-
Type:
System.Type
The type to evaluate.
- value
-
Type:
System.Enum
The value from type to select.
Return Value
Type: System.Collections.Generic.IList<SelectListItem>A list for the given type, possibly extended to include an unrecognized value.
Throws if IsValidForEnumHelper returns false for the given type or if a non-null value has a different type than type.

