I have a sql server table ProjectDetails. The table has following columns ID(PK), ProjectID, Project. I need the values of ProjectID & Project to be populated into the 2 different dropdown list.
Model:
public class ViewModel
{
public int ID { get; set; }
public string Project { get; set; }
public string ProjectID { get; set; }
}
Controller:
[ActionName("DetailsForm")]
[HttpGet]
public ActionResult DetailsForm()
{
try
{
IEnumerable<ViewModel> dropConfig = new List<ViewModel>();
IEnumerable<ViewModel> selectList = floorService.DropDownList();
ViewModel model = new ViewModel()
{
dropConfig = selectList,
};
return View("DetailsForm",model);
}
I have difficulties in figuring out what should go under repository code where I need to execute the stored proc GetProjectDetails which will give me the data from Table ProjectDetails
Please help me with some examples where I can learn to go ahead with my solution. Thanks in advance.
ViewModelclass does not have a property nameddropConfigbut in your controller you have that code. Your code will not compile. Please post code which will compile and tell us which specific part you are having issues with.