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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:40:36+00:00 2026-05-16T18:40:36+00:00

If I have an object that is composed of nested complex types, e.g. a

  • 0

If I have an object that is composed of nested complex types, e.g. a ViewModel that has a List<Fu> and a List<Bar>

public class WarViewModel
{
    List<Fu> Fu { get; set; }
    List<Bar> Bar { get; set; }
}

public class Fu
{
    public int Id {get;set;}
    public Soldier Private { get; set; }
}

public class Bar
{
    public int Id {get;set;}        
    public Soldier Private { get; set; }
}

public class Soldier
{
    public int Id {get;set;}
    public string Name { get; set; }
    public int Age { get; set; }
}

if I had a form that contained 2 select lists, either with Fu or Bar, where each option represented each soldier in the list, and the option had attributes containing Id, Name and Age, such as

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WarViewModel>" %>

<% using (Html.BeginForm("WarAction", "War")) { %>        
    <% foreach (var soldier in Fu) %>
        <select class="fu">
            <option id='<%= soldier.Id %>' age='<%= soldier.Age %>'><%= soldier.Name %></option>
        </select>
    <% } %>

    <% foreach (var soldier in Bar) %>
        <select class="bar">
            <option id='<%= soldier.Id %>' age='<%= soldier.Age %>'><%= soldier.Name %></option>
        </select>
    <% } %>        
<% } %>

What naming convention do I need to use so that when the form is submitted, the following action method’s WarViewModel will be populated with the soldiers that are selected in both lists?

public ActionResult WarAction(WarViewModel war)
{
    return View();
}

My understanding now is that the model binder won’t know soldier is which, so it won’t know which Id is associated with which soldier. Is there a way for me to work around this? I know that the code above won’t validate but I’m trying to implement a proof of concept for myself.

Also, what needs to be changed to make this approach RESTful?

  • 1 1 Answer
  • 1 View
  • 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-16T18:40:37+00:00Added an answer on May 16, 2026 at 6:40 pm

    What your trying to do is already supported:

    http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

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

Sidebar

Related Questions

I have a MovieClip that is composed in a parent (non-display object) class. We
I have an object(A) which has a list composed of objects (B). The objects
I have two tables: object that has object_id column and avalues that have object_id
I have an object that cannot be copied, a NetGame because it has a
I have an object that has pairs of replacement values used for simple encoding
I have an object that has properties, but when I try to access them,
I have a object that contains data from a DB. The object has a
I have been writing several class templates that contain nested iterator classes, for which
I have a data source that is composed of object { groupName, rowName, colName,
I have an object that looks like this { AF : { name :

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.