I'm using mvc4. How can I Bind CuntryName and its values in DropdownList Country?
public class Country
{
public int Cnt_Id { get; set; }
public string Cnt_Name { get; set; }
}
This is my private class
public class HybridEmployee
{
public IEnumerable<Country> GetCount { get; set; }
}
Controller
public ActionResult GetCountry()
{
var x = ObjRepo.GetCountry();
hybrid.GetCount = x;
return View(hybrid);
}
Index.cshtml
@model Mvc_Application.Models.HybridEmployee
@using Mvc_Application.Models
@using (Html.BeginForm("SaveEmp", "Home", FormMethod.Post))
{
@Html.DropDownListFor(x=>x.GetCount.FirstOrDefault().Cnt_Id),new SelectList(Model.GetCount,"","");
}