Created
April 18, 2014 14:50
-
-
Save kmoormann/11048008 to your computer and use it in GitHub Desktop.
Enum to MVC SelectListItemExtension....IN PROGRESS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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