Skip to content

Instantly share code, notes, and snippets.

@kmoormann
Created April 18, 2014 14:50
Show Gist options
  • Save kmoormann/11048008 to your computer and use it in GitHub Desktop.
Save kmoormann/11048008 to your computer and use it in GitHub Desktop.
Enum to MVC SelectListItemExtension....IN PROGRESS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Inventory.Web.Code.Extensions
{
public enum SelectListItemEnumValueOption
{
Name,
Description,
DisplayName,
IntAsString
}
public static class EnumToSelectListItemExtension
{
public static SelectListItem ToSelectListItem(this Enum currentEnum, SelectListItemEnumValueOption textOption, SelectListItemEnumValueOption valueOption)
{
var selectListItem = new SelectListItem();
Type type = currentEnum.GetType();
currentEnum.
var description = da != null ? da.Description : currentEnum.ToString();
return description;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment