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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:48:17+00:00 2026-05-26T06:48:17+00:00

I’m using Asp.Net MVC 2 and I have a situation where I’m building a

  • 0

I’m using Asp.Net MVC 2 and I have a situation where I’m building a Create/Edit form to a class that some of it’s properties are collections. The user can add N items to each collection. My ViewModel is like this:

public class Person  
{  
   public string Name {get; set;}  
   public DateTime BirthDate {get; set;}     
   public IList<Address> Addresses {get; set;}
}

public class Address
{
   public string StreetName {get; set}  
   public int Number {get; set;}  
   public string Neighborhood {get; set;}
}  

It’s a requirement that the user hits the submit button just once, that is, just one form. So I tried to use the solution Steven Sanderson shows here http://blog.stevensanderson.com/2010/07/12/editing-a-variable-length-list-knockout-style/ , but it requires that my view inherits from a IEnumerable. In my scenario I have one person that has many addresses and many telephones, and etc… and not a collection o Person.

I can add the form elements using JQuery, but I don’t know how to do the data binding on the controller.

Can anyone help me with this?

Thanks a lot!

  • 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-05-26T06:48:18+00:00Added an answer on May 26, 2026 at 6:48 am

    Phill Haak have a great post about such scenario:

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

    There are various examples in the post.

    <% for (int i = 0; i < 3; i++) { %>
    
      <%: Html.TextBoxFor(m => m.Addresses[i].StreetName) %>
      <%: Html.TextBoxFor(m => m.Addresses[i].Number) %>
      <%: Html.TextBoxFor(m => m.Addresses[i].Neighborhood) %> 
    
    <% } %>
    

    For adding values via javascript you just need to keep naming conventions:

    <input type="text" name="Addresses[0].StreetName" />
    <input type="text" name="Addresses[0].Number" />
    <input type="text" name="Addresses[0].Neighborhood" />
    
    <input type="text" name="Addresses[1].StreetName" />
    <input type="text" name="Addresses[1].Number" />
    <input type="text" name="Addresses[1].Neighborhood" />
    

    P.S. not sure in the names. Check how it will be generated by the first sample.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to

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.