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

  • Home
  • SEARCH
  • 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 7967401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:41:17+00:00 2026-06-04T06:41:17+00:00

I have a collection of entities, called Accounts. A single user will have multiple

  • 0

I have a collection of entities, called Accounts. A single user will have multiple Accounts and can set percentages for each Account.

The UI will list all the Accounts, the editable field for each Account is the Percentage property. This will be represented by a textbox.

Once the user makes any adjustments, they will post the form back for processing.

I have used MVC in a few other projects and I understand model binding, but I am not sure how to proceed when dealing with a collection of models.

I am not looking for code or for someone to write out the complete answer for me (although, honestly I wouldn’t complain….). I am looking for guidance in the direction to take.

Thanks in advance.

  • 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-04T06:41:21+00:00Added an answer on June 4, 2026 at 6:41 am

    Two things:

    1) You’ll want to use a List/Collection of Account or List/Collection of AccountViewModel in your overarching page view model

    So, you would have

    public class MyPageViewModel
    {
        public Collection<Account> AccountList; 
        //AccountViewModel is what I'd use but for simplicity
        //Other properties for view model
    }
    

    You now have a view model that contains a list of accounts.

    2)

    In your view you have two options.

    a) Just create a for loop to spit out the HTML you want for each account (not especially pretty)

    b) Create an editor template so you don’t have to do anything special
    Your page would then have this.

    @Html.EditorFor(model => model.AccountList)
    

    Here’s how editor templates are set up.

    enter image description here

    This is from a project I’m working on right now. The take away here should be that you add an “EditorTemplates” folder under the view folder that matches what you’re working on. By convention, MVC will look in this folder for a template when you use EditorFor. Now you just insert whatever HTML you want in that strongly typed template (which would take an Account or AccountViewModel object) and you’d be done. No need for a for loop in your view to spit out HTML for each account.

    Really, that would be it at that point. Your post action would model bind to a type of MyPageViewModel which would have the updated data you wanted

    Hope that gets you pointed in the right direction.

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

Sidebar

Related Questions

We have a collection of entities of type called Unit , collection of entities
I have Collection List<Car> . How to compare each item from this collection with
I'm planning to have collection of items stored in a TCollection. Each item will
I have three entities: User , Team , and TeamInvite . Each User has
I have a collection of entities with an any-association, like this: public class CreatedLog
I have a problem adding entities to a collection. public void SaveNotificationUsergroups(int bookingobjectID, int[]
I have two entities: public class Parent() { public ICollection<Child> Children { get; set;
I have a many-to-many relationship between the two entities called events and artists, both
I have a service layer returning a collection of entities : /// <summary> ///
I have a collection of objects in my EF repository called Territories . A

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.