1 /* ****************************************************************************
\r
3 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5 * This software is subject to the Microsoft Public License (Ms-PL).
\r
6 * A copy of the license can be found in the license.htm file included
\r
7 * in this distribution.
\r
9 * You must not remove this notice, or any other, from this software.
\r
11 * ***************************************************************************/
\r
13 namespace System.Web.Mvc {
\r
14 using System.Collections;
\r
15 using System.Diagnostics.CodeAnalysis;
\r
17 [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
\r
18 public class SelectList : MultiSelectList {
\r
20 public SelectList(IEnumerable items)
\r
21 : this(items, null /* selectedValue */) {
\r
24 public SelectList(IEnumerable items, object selectedValue)
\r
25 : this(items, null /* dataValuefield */, null /* dataTextField */, selectedValue) {
\r
28 public SelectList(IEnumerable items, string dataValueField, string dataTextField)
\r
29 : this(items, dataValueField, dataTextField, null /* selectedValue */) {
\r
32 public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue)
\r
33 : base(items, dataValueField, dataTextField, ToEnumerable(selectedValue)) {
\r
34 SelectedValue = selectedValue;
\r
37 public object SelectedValue {
\r
42 private static IEnumerable ToEnumerable(object selectedValue) {
\r
43 return (selectedValue != null) ? new object[] { selectedValue } : null;
\r