Share via


HtmlHelper.DropDownList Method

Definition

Overloads

DropDownList(String, String, IEnumerable<SelectListItem>, Object, Object)

Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute object, and default selection, and that contains the specified list items and default item.

DropDownList(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute dictionary, and default selection, and that contains the specified list items and default item.

DropDownList(String, String, IEnumerable<SelectListItem>, Object)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item.

DropDownList(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item.

DropDownList(String, IEnumerable<SelectListItem>)

Returns an HTML drop-down list control that has the specified name and that contains the specified list items.

DropDownList(String, IEnumerable<SelectListItem>, Object)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items.

DropDownList(String, IEnumerable<SelectListItem>, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items.

DropDownList(String, String, IEnumerable<SelectListItem>)

Returns an HTML drop-down list control that has the specified name, and that contains the specified list items and default item.

DropDownList(String, String, IEnumerable<SelectListItem>, Object, Object)

Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute object, and default selection, and that contains the specified list items and default item.

public System.Web.IHtmlString DropDownList (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValue, object htmlAttributes);
member this.DropDownList : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * obj -> System.Web.IHtmlString
Public Function DropDownList (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValue As Object, htmlAttributes As Object) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

defaultOption
String

The text to display for the default option in the list.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

selectedValue
Object

The value that specifies the item in the list that is selected by default. The item that is selected is the first item in the list that has a matching value, or that matches the items displayed text if the item has no value.

htmlAttributes
Object

An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute dictionary, and default selection, and that contains the specified list items and default item.

public System.Web.IHtmlString DropDownList (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValue, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.DropDownList : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function DropDownList (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValue As Object, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

defaultOption
String

The text to display for the default option in the list.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

selectedValue
Object

The value that specifies the item in the list that is selected by default. The selected item is the first item in the list whose value matches the parameter (or whose text matches, if there is no value.)

htmlAttributes
IDictionary<String,Object>

The names and values of custom attributes for the element.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, String, IEnumerable<SelectListItem>, Object)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item.

public System.Web.IHtmlString DropDownList (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.DropDownList : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function DropDownList (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

defaultOption
String

The text to display for the default option in the list.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

htmlAttributes
Object

An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item.

public System.Web.IHtmlString DropDownList (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.DropDownList : string * string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function DropDownList (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

defaultOption
String

The text to display for the default option in the list.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

htmlAttributes
IDictionary<String,Object>

The names and values of custom attributes for the element.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, IEnumerable<SelectListItem>)

Returns an HTML drop-down list control that has the specified name and that contains the specified list items.

public System.Web.IHtmlString DropDownList (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.DropDownList : string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function DropDownList (name As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, IEnumerable<SelectListItem>, Object)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items.

public System.Web.IHtmlString DropDownList (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.DropDownList : string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function DropDownList (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

htmlAttributes
Object

An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, IEnumerable<SelectListItem>, IDictionary<String,Object>)

Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items.

public System.Web.IHtmlString DropDownList (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.DropDownList : string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function DropDownList (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

htmlAttributes
IDictionary<String,Object>

The names and values of custom attributes for the element.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to

DropDownList(String, String, IEnumerable<SelectListItem>)

Returns an HTML drop-down list control that has the specified name, and that contains the specified list items and default item.

public System.Web.IHtmlString DropDownList (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.DropDownList : string * string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function DropDownList (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString

Parameters

name
String

The value to assign to the name attribute of the HTML select element.

defaultOption
String

The text to display for the default option in the list.

selectList
IEnumerable<SelectListItem>

A list of SelectListItem instances that are used to populate the list.

Returns

The HTML markup that represents the drop-down list control.

Exceptions

Sytem.ArgumentException

name is null or empty.

Applies to