Table of Contents

Class SelectList

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Represents a list that lets users select one item.

public class SelectList : MultiSelectList, IEnumerable<SelectListItem>, IEnumerable
Inheritance
SelectList
Implements
Inherited Members

Constructors

SelectList(IEnumerable)

Initializes a new instance of the SelectList class by using the specified items for the list.

public SelectList(IEnumerable items)

Parameters

items IEnumerable

The items.

SelectList(IEnumerable, object)

Initializes a new instance of the SelectList class by using the specified items for the list and a selected value.

public SelectList(IEnumerable items, object selectedValue)

Parameters

items IEnumerable

The items.

selectedValue object

The selected value.

SelectList(IEnumerable, object, IEnumerable)

Initializes a new instance of the SelectList class by using the specified items for the list, the selected value, and the disabled values.

public SelectList(IEnumerable items, object selectedValue, IEnumerable disabledValues)

Parameters

items IEnumerable

The items used to build each SelectListItem of the list.

selectedValue object

The selected value. Used to match the Selected property of the corresponding SelectListItem.

disabledValues IEnumerable

The disabled values. Used to match the Disabled property of the corresponding SelectListItem.

SelectList(IEnumerable, string, string)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, and the data text field.

public SelectList(IEnumerable items, string dataValueField, string dataTextField)

Parameters

items IEnumerable

The items.

dataValueField string

The data value field.

dataTextField string

The data text field.

SelectList(IEnumerable, string, string, object)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, and a selected value.

public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue)

Parameters

items IEnumerable

The items.

dataValueField string

The data value field.

dataTextField string

The data text field.

selectedValue object

The selected value.

SelectList(IEnumerable, string, string, object, IEnumerable)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, the selected value, and the disabled values.

public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue, IEnumerable disabledValues)

Parameters

items IEnumerable

The items used to build each SelectListItem of the list.

dataValueField string

The data value field. Used to match the Value property of the corresponding SelectListItem.

dataTextField string

The data text field. Used to match the Text property of the corresponding SelectListItem.

selectedValue object

The selected value. Used to match the Selected property of the corresponding SelectListItem.

disabledValues IEnumerable

The disabled values. Used to match the Disabled property of the corresponding SelectListItem.

SelectList(IEnumerable, string, string, string, object)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, the data group field, and the selected value.

public SelectList(IEnumerable items, string dataValueField, string dataTextField, string dataGroupField, object selectedValue)

Parameters

items IEnumerable

The items used to build each SelectListItem of the list.

dataValueField string

The data value field. Used to match the Value property of the corresponding SelectListItem.

dataTextField string

The data text field. Used to match the Text property of the corresponding SelectListItem.

dataGroupField string

The data group field. Used to match the Group property of the corresponding SelectListItem.

selectedValue object

The selected value. Used to match the Selected property of the corresponding SelectListItem.

SelectList(IEnumerable, string, string, string, object, IEnumerable)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, the data group field, the selected value, and the disabled values.

public SelectList(IEnumerable items, string dataValueField, string dataTextField, string dataGroupField, object selectedValue, IEnumerable disabledValues)

Parameters

items IEnumerable

The items used to build each SelectListItem of the list.

dataValueField string

The data value field. Used to match the Value property of the corresponding SelectListItem.

dataTextField string

The data text field. Used to match the Text property of the corresponding SelectListItem.

dataGroupField string

The data group field. Used to match the Group property of the corresponding SelectListItem.

selectedValue object

The selected value. Used to match the Selected property of the corresponding SelectListItem.

disabledValues IEnumerable

The disabled values. Used to match the Disabled property of the corresponding SelectListItem.

SelectList(IEnumerable, string, string, string, object, IEnumerable, IEnumerable)

Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, the data group field. the selected value, the disabled values, and the disabled groups.

public SelectList(IEnumerable items, string dataValueField, string dataTextField, string dataGroupField, object selectedValue, IEnumerable disabledValues, IEnumerable disabledGroups)

Parameters

items IEnumerable

The items used to build each SelectListItem of the list.

dataValueField string

The data value field. Used to match the Value property of the corresponding SelectListItem.

dataTextField string

The data text field. Used to match the Text property of the corresponding SelectListItem.

dataGroupField string

The data group field. Used to match the Group property of the corresponding SelectListItem.

selectedValue object

The selected value. Used to match the Selected property of the corresponding SelectListItem.

disabledValues IEnumerable

The disabled values. Used to match the Disabled property of the corresponding SelectListItem.

disabledGroups IEnumerable

The disabled groups. Used to match the Disabled property of the corresponding SelectListGroup.

Properties

SelectedValue

Gets the list value that was selected by the user.

public object SelectedValue { get; }

Property Value

object

The selected value.