mikaelsnavy
7/21/2017 - 6:43 PM

Drop Down List Split Enums

Drop Down List Split Enums

@Html.DropDownListFor(model => model.Status, Status.GetValues(typeof(Status)).Cast<Status>().Select(v => new SelectListItem
   {
     Text = WebAdministration.Classes.Helpers.SplitCamelCase(v.ToString()),
     Value = ((int)v).ToString()
   }).ToList(), new { @class = "form-control" })
                                       
                                       
    /// <summary>
		/// Takes a camel case string and splits it
		/// </summary>
        public static string SplitCamelCase(string input)
        {
            return System.Text.RegularExpressions.Regex.Replace(input, "([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
        }