This is the sample of the model class
[Required(ErrorMessage = "Department is required")]
[Display(Name = "Department")]
public int SelectedValue { get; set; }
[Required(ErrorMessage = "Department is required")]
[Display(Name = "Department")]
public List<Department> RoleList { get; set; }
This is the view
<div class="col-md-10">
@Html.DropDownListFor(m => m.RoleList, new SelectList(Model.RoleList,"ID", "RoleName","1"), "Please Choose a Department", new { htmlAttributes = new { @class = "form-control"} })
@Html.ValidationMessageFor(model => model.SelectedValue, "",new { @class = "text-danger"})
</div>
The list is populated perfectly from the database. Now when i select the item on the list, the select value has to be sent to the controller
public async Task<ActionResult> Register(RegisterViewModel model)
{
int Selectedvalue = model.SelectedValue;
if (ModelState.IsValid && (model.SelectedValue).ToString() != "0")
{
Here i have made a selection
Error

