SelectList Class

Syntax

public class SelectList : MultiSelectList, IEnumerable<SelectListItem>, IEnumerable

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.Rendering.SelectList

Constructors

SelectList(System.Collections.IEnumerable)
Arguments:
  • items (System.Collections.IEnumerable) –
public SelectList(IEnumerable items)
SelectList(System.Collections.IEnumerable, System.Object)
Arguments:
  • items (System.Collections.IEnumerable) –
  • selectedValue (System.Object) –
public SelectList(IEnumerable items, object selectedValue)
SelectList(System.Collections.IEnumerable, System.String, System.String)
Arguments:
  • items (System.Collections.IEnumerable) –
  • dataValueField (System.String) –
  • dataTextField (System.String) –
public SelectList(IEnumerable items, string dataValueField, string dataTextField)
SelectList(System.Collections.IEnumerable, System.String, System.String, System.Object)
Arguments:
  • items (System.Collections.IEnumerable) –
  • dataValueField (System.String) –
  • dataTextField (System.String) –
  • selectedValue (System.Object) –
public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue)
SelectList(System.Collections.IEnumerable, System.String, System.String, System.Object, System.String)

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

Arguments:
  • items (System.Collections.IEnumerable) – The items used to build each [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) of the list.
  • dataValueField (System.String) – The data value field. Used to match the Value property of the corresponding [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml).
  • dataTextField (System.String) – The data text field. Used to match the Text property of the corresponding [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml).
  • selectedValue (System.Object) – The selected values. Used to match the Selected property of the corresponding [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml).
  • dataGroupField (System.String) – The data group field. Used to match the Group property of the corresponding [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml).
public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue, string dataGroupField)

Properties

SelectedValue()
Return type:System.Object
public object SelectedValue { get; }