Add constructor for the SelectListItem class
This commit is contained in:
parent
381ac2946c
commit
88e14a0bfe
|
|
@ -64,24 +64,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
return new List<SelectListItem>
|
return new List<SelectListItem>
|
||||||
{
|
{
|
||||||
new SelectListItem
|
new SelectListItem(Resources.Common_TriState_NotSet, string.Empty, !value.HasValue),
|
||||||
{
|
new SelectListItem(Resources.Common_TriState_True, "true", (value == true)),
|
||||||
Text = Resources.Common_TriState_NotSet,
|
new SelectListItem(Resources.Common_TriState_False, "false", (value == false)),
|
||||||
Value = string.Empty,
|
|
||||||
Selected = !value.HasValue
|
|
||||||
},
|
|
||||||
new SelectListItem
|
|
||||||
{
|
|
||||||
Text = Resources.Common_TriState_True,
|
|
||||||
Value = "true",
|
|
||||||
Selected = (value == true),
|
|
||||||
},
|
|
||||||
new SelectListItem
|
|
||||||
{
|
|
||||||
Text = Resources.Common_TriState_False,
|
|
||||||
Value = "false",
|
|
||||||
Selected = (value == false),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,16 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SelectListItem
|
public class SelectListItem
|
||||||
{
|
{
|
||||||
|
public SelectListItem() { }
|
||||||
|
|
||||||
|
public SelectListItem(string text, string value, bool selected = false, bool disabled = false)
|
||||||
|
{
|
||||||
|
Disabled = disabled;
|
||||||
|
Selected = selected;
|
||||||
|
Text = text;
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value that indicates whether this <see cref="SelectListItem"/> is disabled.
|
/// Gets or sets a value that indicates whether this <see cref="SelectListItem"/> is disabled.
|
||||||
/// This property is typically rendered as a <code>disabled="disabled"</code> attribute in the HTML
|
/// This property is typically rendered as a <code>disabled="disabled"</code> attribute in the HTML
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue