MVC viewmodel formcollection becomes null for some queries on POST

Hey guys, i've been stumped on this one awhile, rewritten several times, googled to death... MVC is driving me nuts.

For this question I have a database with 3 tables, each a 1 to many relationship to the other,
One Control with Many Procedures, each Procedure has Many Objectives.  
tableControl relates to tableProcedures via a common ControlID
tableObjective relates to tableProcedures via a common ProcedureID

My Controller looks like this:
 [Authorize]
        public ActionResult EditControl(string controlID)
        {
           MyProg.ViewModels.EditControl editControl = new MyProg.ViewModels.EditControl()
            {
                tableControl = repo.GetControl(controlID),
                tableProcedure = repo.ViewProcedureDetails(controlID),
                tableObjective = repo.ViewObjectiveDetails(controlID)
            };
return View(editControl);
}

 [HttpPost]
        public ActionResult EditControl(string controlID, MyProg.ViewModels.EditControl collection)
        { // UpdateModel logic is here 
At this point if I set a breakpoint collection states null for everything but my tableControl.  It seems that is because it is a standard query with just a single table.  Everything works fine if I make the Procedure return only one table but I want to make a single database call which contains all Procedures associated with the controlID have user edit them in the View and on Post save changes to database. 
}

Open in new window


Here is repository, also note I've tried different queries but have not had success except when requesting a single record. Everything displays and is in the collection during the initial Get View
public tableControl GetControl(string controlID) // works
        {
            return db.tableControls.SingleOrDefault(a => a.ControlID == controlID);
        }
public List<tableProcedure> ViewProcedureDetails(string controlID)
        {
            return (from procedures in db.tableProcedures
                    where procedures.ControlID == controlID
                    select procedures).ToList();
        }
public IQueryable<tableProcedure> GetProcedures(string controlID)
        {
            return from procedures in db.tableProcedures
                   where procedures.ControlID == controlID
                   select procedures;
        }
public IEnumerable<tableObjective> ViewObjectiveDetails(string controlID)
        {
            return from objectives in db.tableObjectives
                   join procedures in db.tableProcedures on objectives.ProcedureID equals procedures.ProcedureID
                   where procedures.ControlID == controlID
                   select objectives;
        }

Open in new window


lastly, here's my viewmodel class, tried different ones here as well:
public class EditControl
    {
 public IEnumerable<tableProcedure> ProcedureList { get; set; }
 public tableControl tableControl { get; set; }
 public List<tableProcedure> tableProcedure { get; set; } 
 public IEnumerable<tableControl> editingControl { get; set; }
 public IEnumerable<tableObjective> tableObjective { get; set; }
    }

Open in new window


Like I said, the Get looks good and a breakpoint shows tableProcedure is loaded in with [2] objects, I can access the data, but once the form is submitted and Posted, everything becomes null except tableControl.  Please let me know what I'm doing wrong here so it will no longer be null on Post, Linq to Sql  Thanks!
LVL 5
DigitalTechyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DigitalTechyAuthor Commented:
Thanks for expanding it.  In the mean-time I believe I may have found a solution.  Finally I found a website that addresses the issue, for others that are looking: http://www.mikesdotnetting.com/Article/105/ASP.NET-MVC-Partial-Views-and-Strongly-Typed-Custom-ViewModels

This has a one to many relationship with both partial views and strongly typed custom view models.  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DigitalTechyAuthor Commented:
No one else posted any possible solutions.  I finally found a website that had a potential workaround and it looks like it is the best solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.