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>