'how to get MVC Enum Dropdownlist value in C# [duplicate]

I'm new to MVC. I have a dropdownlist that I created using enum values that works perfectly. However, I want to get the dropdownlist value(MINITRUCK,TRUCK,BIGTRUCK,VAN) , I am unable to get the value the user selects from the dropdownlist into the database table (SQLserver) and the database table column format for the selects is varchar(20) what's wrong in my code? how to get the dropdownlist select in control ? Here is the code....

MODEL\Enumlist.cs :

namespace InfoMIS.Models
public enum CarType 
{

    MINITRUCK,
    TRUCK,
    BIGTRUCK,
    VAN
}

MODEL\application.cs :

 [Display(Name = "Car Type")]
 [StringLength(10)]
 public string CModel { get; set; }

my view :

<div class="col-xl-4 col-md-6 col-12">
      <div class="row">
           <div class="col-xl-4 col-md-4 col-12 form-title">
                 @Html.LabelFor(model => model.CModel)
           </div>
           <div class="col-xl-8 col-12">
           @Html.DropDownList("CarType", new SelectList(Enum.GetValues(typeof(InfoMIS.Models.CarType))), "please choose one", new { @class = "rwd-select" })
          </div>
     </div>
 </div>


Solution 1:[1]

put this code in your view

@{
var carTypes = Enum.GetValues(typeof(CarType)).OfType<CarType>().Select(m => new SelectListItem { Text = m, Value = m }).ToList();
}
....
@Html.DropDownListFor(model => model.CModel, @carTypes, "Select type", new { @class = "form-control" })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serge