Cpo Design

Bind Partial View Model binding during Submit

Pavel Svarc Monday, March 14, 2016 1:17 AM

Class setup


Here is implementation how it should be used

public class ExamResultsFormViewModel
    public PreliminaryInformationViewModel PreliminaryInformation { get; set; }
    public string MemberID { get; set; }
    public string MemberName { get; set; }
    public int PatientID { get; set; }
    public string ConfirmationID { get; set; }
    public bool IsEditable { get; set; }
    #region Select Lists
    public SelectList ProviderOptions { get; set; }

public class PreliminaryInformationViewModel
    public string ProviderName { get; set; }
    public string ProviderID { get; set; }
    public string ServiceLocation { get; set; }


By default the mode binding does not understand the binding and therefore we need to help. To resolve nested class we need to use code as follows


 @Html.Partial("_YourPartialName", Model.Contact, new ViewDataDictionary()
  TemplateInfo = new TemplateInfo()
    HtmlFieldPrefix = "Contact"

Now following this pattern we can create the class.


And here is link to gist  :https://gist.github.com/cpoDesign/b9fd0b76fd15a0f57fee

Related posts

Currenlty there are no related articles.