I have a view with a form. On that form I have some textboxes and 2 dropdownlists.
This is my ViewModel.
public class NewApplicationViewModel
{
public ApplicationData Application { get; set; }
//Selectlists
public SelectList Questionnaires { get; set; }
public SelectList Jobs { get; set; }
}
The ApplicatoinData class looks like this
public class ApplicationData
{
[HiddenInput(DisplayValue = false)]
public Guid Id { get; set; }
[Required]
public ApplicantData Applicant { get; set; }
[Required]
public QuestionnaireData Questionnaire { get; set; }
[Required]
public JobData Job { get; set; }
public string Pdf { get; set; }
}
The "Questionnaire" and te "Job" have to be selected from the dropdownlists. How can a bind the selected value in the dropdown to the object in my "ApplicationData"? To be complete, this is my controller action to hande the form submit.
[HttpPost]
public ActionResult NewApplication([Bind(Prefix="Application")]ApplicationData model)
{
var application = Mapper.Map<ApplicationData, Application>(model);
_applicationRepository.Add(application);
_session.Commit();
return View();
}
Thanks