Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:46:48+00:00 2026-06-12T18:46:48+00:00

How do I bind such a complex model with multiple layers that contain multiple

  • 0

How do I bind such a complex model with multiple layers that contain multiple objects?
Right now I pass the model to the view – (populating a form / a check box tree) and I would like the exact model back (SubjectSelectionModel) but it’s not binding correctly.

Could anyone elaborate on the process I need to take in order to bind these correctly in my view?

View Model:

public class SubjectSelectionModel
{
    public IList<Subject> Subjects { get; set; }
}

Subject Class:

public class Subject
{
    public String Name { get; set; }
    public IList<Bin> Bins { get; set; }

    public Subject()
    {

    }

    public Subject(IList<Course> courses)
    {

    }
}

Bin Class:

public class Bin 
{
    public Subject Subject { get; set; }
    public int Amount { get; set; }

    public IList<Foo> Foos { get; set; }
}

Foo Class:

public class Foo
{
    public int Number { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:46:49+00:00Added an answer on June 12, 2026 at 6:46 pm

    This is where Editor Templates come in handy. Rather than messing around with this, you can use simple editor templates to handle all the grunt work for you.

    You would create several templates in ~/Views/Shared/EditorTemplates, and then in your primary view it should look like this:

    View.cshtml

    @model SubjectSelectionModel
    @using(Html.BeginForm()) {
        @EditorFor(m => m.Subjects)
        <input type="submit" />
    }
    

    Subject.cshtml

    @model Subject
    @Html.EditorFor(m => m.Name)
    @Html.EditorFor(m => m.Bins)
    

    Bin.cshtml (I assume you don’t want to render Subject, this would be an infinite loop)

    @model Bin
    @Html.EditorFor(m => m.Amount)
    @Html.EditorFor(m => m.Foos)
    

    Foo.cshtml

    @model Foo
    @Html.EditorFor(m => m.Number)
    

    Obviously, you may want to change the html formatting to whatever you want, but that’s essentially it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the simplest way to bind two select elements in a form, such that
How do I get Grails data binding to correctly bind referenced objects (such as
How can you make an own function in PHP such that I can bind
whether possible Bind complex list to DataSource a GridView with all members? such as:
I'm using a PasswordBox which exposes a dependency property such that I can bind
I noticed that the Ninject API has calls such as Bind<ISomething>().DoSomethingElse(); How is this
If you bind a control in a FormView using two way binding (such as
I am getting the following error Databinding methods such as Eval(), XPath(), and Bind()
boost::bind overloads several operators for its placeholders: For convenience, the function objects produced by
Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.