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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:27:02+00:00 2026-06-01T03:27:02+00:00

Suppose I have the view models below. public class CustomerListViewModel { public IEnumerable<CustomerViewModel> Customers

  • 0

Suppose I have the view models below.

public class CustomerListViewModel {
  public IEnumerable<CustomerViewModel> Customers { get; set; }
}

public class CustomerViewModel {
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public string Email { get; set; }
  public int Age { get; set; }
}

I want to display the list of Customers in my view inside a for-each loop. I also want to use DisplayFor to show the values with conventions applied (as opposed to just outputting the property as-is: customer.Age). With ASP.NET MVC, I used to just ignore the lambda variable in my expression (as was similarly discovered by the asker of this question).

<% foreach (var customer in Model.Customers) { %>
  ...
  <li><%: this.DisplayFor(m => customer.Age) %></li>
<% } %>

However, I get an error with FubuMVC if I do this.

Unable to cast object of type ‘System.Reflection.RtFieldInfo’ to type
‘System.Reflection.PropertyInfo’.

Must I use a partial to render each customer with DisplayFor appropriately?

Thanks in advance!

  • 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-01T03:27:03+00:00Added an answer on June 1, 2026 at 3:27 am

    In this particular use of display for:

    <%: this.DisplayFor(m => customer.Age) %>
    

    The overload is looking for an Expression that refers to a member of m. The use of “customer” here is what is causing the reflection exception.

    There is an additional overload here: https://github.com/DarthFubuMVC/fubumvc/blob/master/src/FubuMVC.Core/UI/FubuPageExtensions.cs#L229

    This one lets you explicitly specify the model type and instance:

    <%: this.DisplayFor<Customer>(customer, c => c.Age) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose, I have models: public class Person { public sting Name {get;set;} public List<Book>
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
Suppose I have: public class foobar { public int lorem; public int ipsum; }
Suppose I have string Name and Image Photo as properties of a class in
Suppose I have a partial view called UserDetails whose @model clause is set to
Suppose I have a view with the following control (DataContext is properly set to
Suppose I have a scroll view in a view & a scroll view's size
Suppose I'm implementing an MVP pattern and I have a view interface as such:
Suppose I have an IEnumerable such as a List(TValue) and I want to keep
I have a question about MVC. Particularly about models. Suppose that I have a

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.