HtmlHelperSelectExtensions.DropDownList 方法

定义

重载

DropDownList(IHtmlHelper, String)

返回 的单选 HTML <select> 元素 expression。 基于具有全名的ViewData条目添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:具有全名的ModelState条目,或expression针对 Model求值的 。 有关“全名”的详细信息,请参阅 Name(String)

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>)

返回 的单选 HTML <select> 元素 expression。 基于 selectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

DropDownList(IHtmlHelper, String, String)

返回 的单选 HTML <select> 元素 expression。 添加<基于 optionLabel 的选项元素以及具有全名的ViewData条目。> 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:具有全名的ModelState条目,或expression针对 Model求值的 。 有关“全名”的详细信息,请参阅 Name(String)

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

返回 的单选 HTML <select> 元素 expression。 基于 selectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

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

返回 的单选 HTML <select> 元素 expression。 基于 optionLabelselectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

DropDownList(IHtmlHelper, String)

返回 的单选 HTML <select> 元素 expression。 基于具有全名的ViewData条目添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:具有全名的ModelState条目,或expression针对 Model求值的 。 有关“全名”的详细信息,请参阅 Name(String)

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String) As IHtmlContent

参数

htmlHelper
IHtmlHelper

IHtmlHelper此方法扩展的实例。

expression
String

相对于当前模型的表达式名称。

返回

包含 <select> 元素的新 IHtmlContent

注解

HtmlFieldPrefix合并 和 expression 以设置 <select> 元素的“name”属性。 expression清理以设置元素的“id”属性。

具有全名的 ViewData 条目必须是对象的非null 集合 SelectListItem

适用于

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>)

返回 的单选 HTML <select> 元素 expression。 基于 selectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlContent

参数

htmlHelper
IHtmlHelper

IHtmlHelper此方法扩展的实例。

expression
String

相对于当前模型的表达式名称。

selectList
IEnumerable<SelectListItem>

对象的集合SelectListItem,用于使用 <optgroup> 和 <option> 元素填充 <select> 元素。 如果 null为 ,则 ViewData 使用具有全名的条目,并且该条目必须是 对象的集合 SelectListItem

返回

包含 <select> 元素的新 IHtmlContent

注解

HtmlFieldPrefix合并 和 expression 以设置 <select> 元素的“name”属性。 expression清理以设置元素的“id”属性。

适用于

DropDownList(IHtmlHelper, String, String)

返回 的单选 HTML <select> 元素 expression。 添加<基于 optionLabel 的选项元素以及具有全名的ViewData条目。> 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:具有全名的ModelState条目,或expression针对 Model求值的 。 有关“全名”的详细信息,请参阅 Name(String)

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::String ^ optionLabel);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, string optionLabel);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, optionLabel As String) As IHtmlContent

参数

htmlHelper
IHtmlHelper

IHtmlHelper此方法扩展的实例。

expression
String

相对于当前模型的表达式名称。

optionLabel
String

默认空项的文本。 如果参数为 null,则不包括此类项。

返回

包含 <select> 元素的新 IHtmlContent

注解

HtmlFieldPrefix合并 和 expression 以设置 <select> 元素的“name”属性。 expression清理以设置元素的“id”属性。

具有全名的 ViewData 条目必须是对象的非null 集合 SelectListItem

适用于

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

返回 的单选 HTML <select> 元素 expression。 基于 selectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::Object ^ htmlAttributes);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, object htmlAttributes);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlContent

参数

htmlHelper
IHtmlHelper

IHtmlHelper此方法扩展的实例。

expression
String

相对于当前模型的表达式名称。

selectList
IEnumerable<SelectListItem>

对象的集合SelectListItem,用于使用 <optgroup> 和 <option> 元素填充 <select> 元素。 如果 null为 ,则 ViewData 使用具有全名的条目,并且该条目必须是 对象的集合 SelectListItem

htmlAttributes
Object

一个 Object ,其中包含 select> 元素的 <HTML 属性。 或者,一个 IDictionary<TKey,TValue> 包含 HTML 属性的 实例。

返回

包含 <select> 元素的新 IHtmlContent

注解

HtmlFieldPrefix合并 和 expression 以设置 <select> 元素的“name”属性。 expression清理以设置元素的“id”属性。

适用于

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

返回 的单选 HTML <select> 元素 expression。 基于 optionLabelselectList添加<选项>元素。 如果选项 (null 非) 或Text与中找到的第一个<非null值匹配,则向Value选项>添加“selected”属性:ModelState具有全名的条目、ViewData (全名项(除非使用 而不是 selectList) )或expression针对 Model计算的 。 有关“全名”的详细信息,请参阅 Name(String)

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::String ^ optionLabel);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, string optionLabel);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem), optionLabel As String) As IHtmlContent

参数

htmlHelper
IHtmlHelper

IHtmlHelper此方法扩展的实例。

expression
String

相对于当前模型的表达式名称。

selectList
IEnumerable<SelectListItem>

对象的集合SelectListItem,用于使用 <optgroup> 和 <option> 元素填充 <select> 元素。 如果 null为 ,则 ViewData 使用具有全名的条目,并且该条目必须是 对象的集合 SelectListItem

optionLabel
String

默认空项的文本。 如果参数为 null,则不包括此类项。

返回

包含 <select> 元素的新 IHtmlContent

注解

HtmlFieldPrefix合并 和 expression 以设置 <select> 元素的“name”属性。 expression清理以设置元素的“id”属性。

适用于