Description
I have a payment page that contains a form for entering bank account information. I encapsulated bank account information in a model / editor template. The page itself has its own viewing model, which, as it turned out, contains the BankAccount property, which will be passed to the editor.
[[Show models]]
public class PaymentPageModel {
public SomeProperty1 { get; set; }
public SomeProperty2 { get; set; }
public BankAccount BankAccount { get; set; }
...
}
public class BankAccount {
public int BankAccountTypeID { get; set; }
public string BankName { get; set; }
public string ABACode { get; set; }
public string AccountNumber { get; set;}
public IEnumerable<SelectListItem> BankAccountTypes {
get { ...
}
}
[[HTML Payment Page Page]]
<% using (Html.BeginForm()) { %>
<%: Html.EditorFor(m => m.BankAccount) %>
...
<% } %>
[[Editor Template]
...
<%: Html.DropDownListFor(m => m.BankAccountTypeID, Model.BankAccountTypes) %>
...
Problem
Initially, this worked great when I strictly printed the "Payment" page directly in the BankAccount model. The drop-down list was filled correctly, and the correct value was selected from the model.
, PaymentPageModel, BankAccount . HTML . , HTML , DropDownList. BankAccountTypes, . , , , IS, , DropDownList.
HTML- , , /.
.