Skip to content

Instantly share code, notes, and snippets.

@cymen
Created June 10, 2012 05:54
Show Gist options
  • Save cymen/2904050 to your computer and use it in GitHub Desktop.
Save cymen/2904050 to your computer and use it in GitHub Desktop.
public static class SelectListExtension
{
public static IEnumerable<selectlistitem> WithDefault(this IEnumerable<selectlistitem> list, string defaultLabel = "Select one...", string value = "")
{
return (new[] { new SelectListItem { Text = defaultLabel, Value = value } }).Concat(list);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment