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

  • Home
  • SEARCH
  • 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 674583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:43:23+00:00 2026-05-14T00:43:23+00:00

I’m getting started with FubuMVC and I have a simple Customer -> Order relationship

  • 0

I’m getting started with FubuMVC and I have a simple Customer -> Order relationship I’m trying to display using nested partials. My domain objects are as follows:

public class Customer
{
    private readonly IList<Order> orders = new List<Order>();

    public string Name { get; set; }
    public IEnumerable<Order> Orders
    {
        get { return orders; }
    }

    public void AddOrder(Order order)
    {
        orders.Add(order);
    }
}

public class Order
{
    public string Reference { get; set; }
}

I have the following controller classes:

public class CustomersController
{
    public IndexViewModel Index(IndexInputModel inputModel)
    {
        var customer1 = new Customer { Name = "John Smith" };
        customer1.AddOrder(new Order { Reference = "ABC123" });

        return new IndexViewModel { Customers = new[] { customer1 } };
    }
}

public class IndexInputModel
{
}

public class IndexViewModel
{
    public IEnumerable<Customer> Customers { get; set; }
}

public class IndexView : FubuPage<IndexViewModel>
{
}

public class CustomerPartial : FubuControl<Customer>
{
}

public class OrderPartial : FubuControl<Order>
{
}

IndexView.aspx: (standard html stuff trimmed)

<div>
    <%= this.PartialForEach(x => x.Customers).Using<CustomerPartial>() %>
</div>

CustomerPartial.ascx:

<%@ Control Language="C#" Inherits="FubuDemo.Controllers.Customers.CustomerPartial" %>
<div>
    Customer
    Name: <%= this.DisplayFor(x => x.Name) %> <br />    
    Orders: (<%= Model.Orders.Count() %>) <br />

    <%= this.PartialForEach(x => x.Orders).Using<OrderPartial>() %>
</div>

OrderPartial.ascx:

<%@ Control Language="C#" Inherits="FubuDemo.Controllers.Customers.OrderPartial" %>
<div>
    Order <br />
    Ref: <%= this.DisplayFor(x => x.Reference) %>
</div>

When I view Customers/Index, I see the following:

Customers 
Customer Name: John Smith 
Orders: (1) 

It seems that in CustomerPartial.ascx, doing Model.Orders.Count() correctly picks up that 1 order exists. However PartialForEach(x => x.Orders) does not, as nothing is rendered for the order. If I set a breakpoint on the Order constructor, I see that it initially gets called by the Index method on CustomersController, but then it gets called by FubuMVC.Core.Models.StandardModelBinder.Bind, so it is getting re-instantiated by FubuMVC and losing the content of the Orders collection.

This isn’t quite what I’d expect, I would think that PartialForEach would just pass the domain object directly into the partial. Am I missing the point somewhere? What is the ‘correct’ way to achieve this kind of result in Fubu?

Update: In case it helps, this is the top few lines of the stacktrace the first time the Order constructor gets hit:

at FubuDemo.Customer..ctor()
at FubuDemo.Controllers.Customers.CustomersController.Index(IndexInputModel inputModel)
at lambda_method(ExecutionScope , CustomersController , IndexInputModel )
at FubuMVC.Core.Behaviors.OneInOneOutActionInvoker`3.performInvoke()

And the second time:

at FubuDemo.Customer..ctor()
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at FubuMVC.Core.Models.StandardModelBinder.Bind(Type type, IBindingContext context)
at FubuMVC.Core.Runtime.ObjectResolver.BindModel(Type type, IBindingContext context)
at FubuMVC.Core.Runtime.ObjectResolver.BindModel(Type type, IRequestData data)
at FubuMVC.Core.Diagnostics.RecordingObjectResolver.BindModel(Type type, IRequestData data)
at FubuMVC.Core.Runtime.FubuRequest.<>c__DisplayClass2.<.ctor>b__0(Type type)
at FubuMVC.Core.Util.Cache`2.Retrieve(KEY key)
at FubuMVC.Core.Util.Cache`2.get_Item(KEY key)
at FubuMVC.Core.Runtime.FubuRequest.Get[T]()
  • 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-14T00:43:24+00:00Added an answer on May 14, 2026 at 12:43 am

    Jon:

    PartialForEach does not new up new models, it passes the models you pass (i.e. x.Orders).

    It looks like the problem you’re facing is because you did not add “.Using” in your CustomerPartial.ascx

    In CustomerPartial.ascx, change

    <%= this.PartialForEach(x => x.Orders) %>

    to

    <%= this.PartialForEach(x => x.Orders).Using<OrderPartial>() %>

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't

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.