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 249311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:25:01+00:00 2026-05-11T21:25:01+00:00

I have a View with a table representing an employee’s timesheet. Days across the

  • 0

I have a View with a table representing an employee’s timesheet. Days across the top, projects down the side, with each day/project intersection containing two values for regular hours and overtime.

The (simplified) class definitions for the page model are:

public class TimesheetFormModel {
    public List<Project> Projects;
    // other things...
}
public class Project {
    public string Name;
    public List<WorkUnit> WorkUnits;
}
public class WorkUnit {
    public DateTime Date;
    public decimal RegularHours;
    public decimal OvertimeHours;
}

The form elements on the page are named as follows in an attempt to get the DefaultModelBinder to pick up on them.

model.Projects[0].Name // "New Project"
model.Projects[0].WorkUnits[0].Date // "5/23/2009 12:00:00 AM"
model.Projects[0].WorkUnits[0].RegularHours // 0
model.Projects[0].WorkUnits[0].OvertimeHours // 0

model.Projects[0].WorkUnits[1].Date // "5/24/2009 12:00:00 AM"
model.Projects[0].WorkUnits[1].RegularHours // 0
model.Projects[0].WorkUnits[1].OvertimeHours // 0

model.Projects[0].WorkUnits[2].Date // "5/25/2009 12:00:00 AM"
model.Projects[0].WorkUnits[2].RegularHours // 0
model.Projects[0].WorkUnits[2].OvertimeHours // 0

// etc.

When the view is submitted however, the model parameter isn’t being completely populated. model.Projects contains projects, but the Project‘s WorkUnits field is empty. Does the DefaultModelBinder support nested collections like I’m trying to do? If not, what should I do?

  • 1 1 Answer
  • 3 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-05-11T21:25:01+00:00Added an answer on May 11, 2026 at 9:25 pm

    I eventually figured out why DefaultModelBinder wasn’t picking up on the properties of WorkUnit: Because they weren’t properties, they were fields. DefaultModelBinder only works with properties. Changing the class definition of WorkUnit and Project to use fields made everything click:

    public class Project {
        public IList<WorkUnit> WorkUnits { get; set; }
        public string Name { get; set; }
    }
    
    public class WorkUnit {
        public DateTime Date { get; set; }
        public decimal RegularHours { get; set; }
        public decimal OvertimeHours { get; set; }
    }
    

    (Note: The source code in the original question had Project.Name defined as a field, in my actual code it was a property. This is why the Projects list was getting populated but WorkUnits wasn’t.)

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

Sidebar

Related Questions

I have a table view of custom cells representing individual uploads and each cell
I have two tables nested (master view) for representing my data. The parent table
So say that I have a table view that has a UINavigationController. On top
I have a view that displays a table: rows represent days - one row
I have a table representing values of source file metrics across project revisions, like
I have a view table which is a union of two separate tables (say
I have view controller, into the view i have put a table view, and
I have table View with grouped style with three sections. Get information from dictionary
I have a table view of peoples names and when I click on one
I have a table view with numerous cells. When I press one, a tick

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.