Hi,
I'm not sure how to get ALL of my values from the view. I am using a strongly typed view model called ApplicationViewModel, here is the code:
public Application Application { get; private set; }
public SelectList AccountTypes { get; private set; }
public ApplicationViewModel(Application application, IEnumerable<AccountType> accountTypes)
{
Application = application;
AccountTypes = new SelectList(accountTypes, "AccountTypeID", "AccountTypeName", application.AccountTypeID);
}
When the form loads for the first time the dropdown populates correctly, and it validates correctly. Here is my dropdown code:
<%: Html.DropDownListFor(m => m.Application.AccountType, Model.AccountTypes, "-- Select --")%>
<%: Html.ValidationMessageFor(m => m.Application.AccountType) %>
When I click the submit button then I want to get all the values on the form, including the value selected in the dropdown. I'm not sure what I am doing wrong. In my Create action it is setting the properties of the Application class to the values of the textboxes. But it is not setting AccountType / AccountTypeID. How do I set this? Is my Create Acction incorrect? Here is my Create action:
[HttpPost]
public ActionResult Create(Application application)
{
}
Please could someone advise?
Thanks.