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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:12:27+00:00 2026-06-04T14:12:27+00:00

I have an action that creates a List and returns it to my view..

  • 0

I have an action that creates a List and returns it to my view..

public ActionResult GetCustomers()
    {
        return PartialView("~/Views/Shared/DisplayTemplates/Customers.cshtml", UserQueries.GetCustomers(SiteInfo.Current.Id));
    }

And in the “~/Views/Shared/DisplayTemplates/Customers.cshtml” view I have the following:

@model IEnumerable<FishEye.Models.CustomerModel>
@Html.DisplayForModel("Customer")

Then I have in the “~/Views/Shared/DisplayTemplates/Customer.cshtml” view:

@model FishEye.Models.CustomerModel
@Model.Profile.FirstName

I am getting the error:

The model item passed into the dictionary is of type System.Collections.Generic.List`1[Models.CustomerModel]', but this dictionary requires a model item of type 'Models.CustomerModel'.

Shouldn’t it display the Customer.cshtml for every item in the collection in the Customers.cshtml?

Help!

  • 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-04T14:12:28+00:00Added an answer on June 4, 2026 at 2:12 pm

    I am not sure why you are calling a partial view like this. If it is a Customer Specific view, why not put it under Views/Customer folder ? Remember ASP.NET MVC is more of Conventions. so i would always stick with the conventions (unless abosultely necessary to configure myself) to keep it simple.

    To handle this situation, i would do it in this way,

    a Customer and CustomerList model/Videmodel

    public class CustomerList
    {
        public List<Customer> Customers { get; set; }
        //Other Properties as you wish also
    }
    
    public class Customer
    {
        public string Name { get; set; }
    }
    

    And in the action method, i would return an object of CustomerList class

    CustomerList customerList = new CustomerList();
    customerList.Customers = new List<Customer>();
    customerList.Customers.Add(new Customer { Name = "Malibu" });
    // you may replace the above manual adding with a db call.
    return View("CustomerList", customerList);
    

    Now there should be a view called CustomerList.cshtml under Views/YourControllerName/ folder. That view should look like this

    @model CustomerList
    <p>List of Customers</p>
    @Html.DisplayFor(x=>x.Customers)
    

    Have a view called Customer.cshtml under Views/Shared/DisplayTemplates with this content

    @model Customer
    <h2>@Model.Name</h2>
    

    This will give you the desired output.

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

Sidebar

Related Questions

If i have a controller action Create that returns a view with the following
i have an action that return a file content. i added: Response.AddHeader(Content-Disposition, attactment; filename:\
Suppose I have an action that returns an rendered asp.net mvc control and send
I have a partial view that shows a list of Categories . I'd like
I have an action which create QMessageBox. In that dialog I want to print
I have a create action for a form that potentially generates errors (i.e. first
I have a create action in the controller that I use for a form
I have an action that relies on User.Identity.Name to get the username of the
I have an Action that basically adds an item to a cart, the only
I have an action that lets the customer preview system email messages and i

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.