EnumHelper.GetSelectList Method

 

Gets a list SelectListItem objects for the provided values.

Namespace:   System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticGetSelectList(ModelMetadata)

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

System_CAPS_pubmethodSystem_CAPS_staticGetSelectList(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.

System_CAPS_pubmethodSystem_CAPS_staticGetSelectList(Type)

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

System_CAPS_pubmethodSystem_CAPS_staticGetSelectList(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.

Return to top

EnumHelper.GetSelectList Method (ModelMetadata)

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

public static IList<SelectListItem> GetSelectList(
	ModelMetadata metadata
)

Parameters

metadata
Type: System.Web.Mvc.ModelMetadata

The model metadata to evaluate.

Return Value

Type: System.Collections.Generic.IList<SelectListItem>

A list for the given metadata.

Throws if IsValidForEnumHelper returns false for the given metadata.

Return to top

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.

public static IList<SelectListItem> GetSelectList(
	ModelMetadata metadata,
	Enum 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.

Return to top

EnumHelper.GetSelectList Method (Type)

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

public static IList<SelectListItem> GetSelectList(
	Type type
)

Parameters

type
Type: System.Type

The type to evaluate.

Return Value

Type: System.Collections.Generic.IList<SelectListItem>

A list for the given type.

Throws if IsValidForEnumHelper returns false for the given type.

Return to top

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.

public static IList<SelectListItem> GetSelectList(
	Type type,
	Enum 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.

Return to top
Show: