Skip to content

Instantly share code, notes, and snippets.

View nickalbrecht's full-sized avatar

Nick Albrecht nickalbrecht

View GitHub Profile
@nickalbrecht
nickalbrecht / SelectListExtensionMethods.cs
Last active November 5, 2022 19:57
SelectListItem Extension Methods for DropDowns in MVC Core. Added ability to specify the option's Group, and for some bug fixes, more XML docs
public static class SelectListExtensionMethods
{
/// <summary>
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when the user needs to pick a value.
/// </summary>
public static readonly SelectListItem DefaultEmptySelectListItem = new SelectListItem() { Text = "-- Pick One --", Value = string.Empty };
/// <summary>
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when not picking a value is the same as using as of the possible choices (meant for filtering typically)
/// </summary>
public static readonly SelectListItem AnySelectListItem = new SelectListItem() { Text = "-- Any --", Value = string.Empty };