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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:07:35+00:00 2026-05-11T07:07:35+00:00

I have a form which contains a whole heap of data entry fields that

  • 0

I have a form which contains a whole heap of data entry fields that will be completed by the user including some elements where the user can dictate how many of the same items they will enter. This is as is being used in Phil Haack’s blog entry Model Binding To A List.

I am successfully using JQuery to create the extra form elements, correctly indexed, etc. My issue is the best way to actually read these within my Controller. The Controller in the article only expects one object, IList<Product> whereas my Controller already expects a FormCollection form and now I am trying to also send it an IList<Itmes> as well.

Should I be adding this to the parameters expected by the Controller or accessing via form[‘items’] or something else?

View

<form action='/MyItems/Add' method='post'>    <input type='text' name='Title' value='' />     <input type='hidden' name='myItem.Index' value='0' />    <input id='item[0].Amount' name='item[0].Amount' type='text' value='' />    <input id='item[0].Name' name='item[0].Name' type='text' value='' />     <input type='hidden' name='myItem.Index' value='1' />    <input id='item[1].Amount' name='item[1].Amount' type='text' value='' />    <input id='item[1].Name' name='item[1].Name' type='text' value='' /> </form> 

Controller

public ActionResult Add(FormCollection form) {     string Title = form['Title'];     List<Item> Items = form['items'].ToList(); } 

DTO

public class Item() {     int Amount {get; set; };     string Name {get; set; }; } 
  • 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. 2026-05-11T07:07:36+00:00Added an answer on May 11, 2026 at 7:07 am

    I have decided to work with exclusively with the FormCollection rather than muddying the waters with some data being passed through using FormCollection and other data being mapped to a List by the framework. The below code takes the items and hydrates the DTO manually. This works nicely and allows me to do some other things within my code that were not possible mapping directly to a List.

    List<Item> itemList = new List<Item>(); int i = 0;  while ( form['item[' + i + '].Amount'] != null) {     itemList.Add(new Item()         {             Amount = Convert.ToInt32(form[String.Format('item[{0}].Amount',i )]),             Name = form[String.Format('item[{0}].Name',i )]         }); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a macro for excel which will pop up form that contains
I have a form which contains a whole bunch of checkboxes and some other
I have a php file that contains a form (which contains 2 input boxes
I have a form MainForm which is a Windows Forms form that contains many
I have a child page LoginContent.aspx which contains a login form. If the user
I need to make the program which have one form that contains PNG image
For example we have priority_queue<int> s; which contains some elements. What will be correct
i have a page,say abc.html, that is having a small form with some fields.
I have a form which contains list of data, I added a checkbox in
i have a website page that contains only data of which one field gives

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.