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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:47:57+00:00 2026-06-08T06:47:57+00:00

I have problem when I am trying to pass values back from my page

  • 0

I have problem when I am trying to pass values back from my page which contains the same partial view twice.
My class definiton is like below:

public class Account : IEntity
{

    public decimal CurrentBalance { get; set; }
    public List<Person> AccountHolders { get; set; }
    //to get round the non-existing enum support in EF4.3 wrap enum to int
    public int StatusValue { get; set; }
    public AccountStatus Status { get { return (AccountStatus)StatusValue; } set { StatusValue = (int) value; } }

    public DateTime AccountOpenDate { get; set; }
    public DateTime AccountCloseDate { get; set; }
    public DateTime AccountSuspensionDate { get; set; }
    }

It has a List of Person , which I made a partial view for (for a single one).

<fieldset>
    <legend>Person</legend>

    <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.Age)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Age)
        @Html.ValidationMessageFor(model => model.Age)
    </div>
</fieldset>

In the Create page for the Account I include 2 of the partial views I created as below.

 <div id="Person1">
        @Html.Partial("_CreateAccountHolder" )
    </div>

     <div id="Person2">
        @Html.Partial("_CreateAccountHolder")
    </div>

When I look at what is posted back, it contains the values (Name and Age as the properties of Person) I put in the form values of the page and I have have the tow of them as expected:
CurrentBalance=19&Status=Closed&AccountOpenDate=12%2F12%2F2012&Name=mustafa&Age=20&Name=sofia&Age=20&AccountCloseDate=12%2F12%2F2012&AccountSuspensionDate=12%2F12%2F2012

But when I look at my create method on my controller I see the AccountHolder list as null. I tried with various signatures…
public ActionResult Create(Account personalaccount, Person [] accountHolders)
public ActionResult Create(Account personalaccount, List accountHolders)

If I only have one partial view of Person and have my controller like this, I can see the Person object bound correctly.
public ActionResult Create(Account personalaccount, Person accountHolder)

Any ideas as to where I am going wrong?

  • 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-06-08T06:47:58+00:00Added an answer on June 8, 2026 at 6:47 am

    If I understand your scenario correctly one way to accomplish this is to use Editor Templates instead of partial views. I have a little write up about them here:

    codenodes.wordpress.com – MVC3 Editor Templates

    To create an Editor Template:

    • if you don’t already have a folder called “EditorTemplates” in the web project of your solution then create one in the Views\Shared folder.
    • add a new partial view and name it the same as the model you’re rendering, in your case Person, so you would call it Person.cshtml (I know partial views are supposed to start with an underscore “_” but for an Editor Template it needs to be named the same as the model).
    • paste the code from your “_CreateAccountHolder” partial view into the new Person.cshtml Editor Template.
    • in your Create page render your AccountHolders list thusly:
    <div id="People">
        @Html.EditorFor(x => x.AccountHolders)
    </div>
    

    If you need to have individual divs around each Person then you can add these to your Editor Template. The good thing about Editor Templates is that you only need a single call to the template even if you have multiple Person objects in your list – no need to loop or anything like that as the template automatically renders each Person object. It also names the field correctly so it should post back something like this if for example you have 2 Person objects in your collection:

    AccountHolders[0].Name
    AccountHolders[0].Age
    AccountHolders[1].Name
    AccountHolders[1].Age
    

    Here’s the code for your Editor Template:

    @model Person
    
    <fieldset>
        <legend>Person</legend>
    
        <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.Age)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Age)
            @Html.ValidationMessageFor(model => model.Age)
        </div>
    </fieldset>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem trying to hide .php extension from the url I have
I have a very weird problem while trying to pass and SQL query using
I have a problem trying to turn my python code into an executable using
I have a problem trying to register my own Event/Listener to the event dispatcher.
I have a problem trying to design some generic storage.. Basically I have the
I have a problem trying to edit. I work with Areas for better management
I implemented the table sorter yesterday and i have a problem trying to change
I have a problem when trying to count in PHP using a button and
I have a problem when trying to execute this update statement (below) using C#
I have this problem when trying to run hello world program using android SDK.

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.