YesNoList

.YesNoList()

Creates a drop down list SelectList containing null, Yes, No.

Method

public static SelectList YesNoList(bool allowNull = true, YesNo selectedValue = YesNo.Null)
bool allowNull = true

Does the first item contain a null or blank entry, or restrict the option to purely Yes and No.

YesNo selectedValue
Default: YesNo.Null

The selected option of the SelectList to show the first time the list is displayed. Any posted back values will automatically show the selected value so no need to set this option again.

public enum YesNo { Null, Yes, No };

Example

C#
ViewBag.YesNo = SiUtil.YesNoList();