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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:35:33+00:00 2026-05-27T04:35:33+00:00

Consider the following data classes: class TopLevel { public TopLevel() { collection = new

  • 0

Consider the following data classes:

class TopLevel
{
    public TopLevel()
    {
        collection = new Item[3];
    }

    public string Name { get; set; }
    public Item[] collection { get; set; }
}

class Item
{
    public string Name { get; set; }
    public string Value { get; set; }
}

I made an Editor Template for Item:

   <div class="editor-label">
        @Html.LabelFor(model => model.Name)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Name)
        @Html.ValidationMessageFor(model => model.Name)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Value)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Value)
        @Html.ValidationMessageFor(model => model.Value)
    </div>

My create csthml for TopLevel looks like this:

@using(Html.BeginForm()) 
{
    @Html.LabelFor( m => m.Name )
    @Html.EditorFor( m => m.Name )
    @Html.ValidationMessageFor( m => m.Name )

    for (int i = 0; i < Model.Collection.Count(); i++)
    {
        @Html.EditorFor(m => m.Collection[i])
    }

    <input type="submit" value="Submit"/>
}

But in my controller

[HttpPost]
public ActionResult Create( TopLevel tl )
{
    //tl.Collection contains three null Items.
}

The Item’s that make up Collection in my TopLevel class do not get created. Is there a way to accomplish this?

  • 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-27T04:35:33+00:00Added an answer on May 27, 2026 at 4:35 am

    See this article for a solution. The magic is contained in the using(Html.BeginCollectionItem("...")) block.

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

Sidebar

Related Questions

Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider the following data Predicate = Pred Name Arity Arguments type Name = String
Consider the following data structure: List<Person> People; class Person { List<Car> Cars; List<Hobby> Hobbies;
Consider following class class test { public: test(int x){ cout<< test \n; } };
Consider the following code. public interface IFoo { } public class Bar { public
Consider the following class in a file MyClass.cs using System; public class MyClass :
Background To replace invalid zip codes. Sample Data Consider the following data set: Typo
Consider the following data set in a book table (group_id, title, check_out_date): > 1
Consider the following: class A{ //data members void foo() { bar();//is this possible? or
Consider following simple DAO example: public abstract class DAOFactory { public abstract AccountDAO getAccountDAO();

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.