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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:10:53+00:00 2026-05-25T22:10:53+00:00

I am trying to display a list in a View, how to fix this

  • 0

I am trying to display a list in a View, how to fix this error?

The model item passed into the dictionary is of type
‘System.Data.Objects.ObjectQuery1[System.Linq.IGrouping2[System.Int32,mvc3Post.Models.Contact]]’,
but this dictionary requires a model item of type
‘System.Collections.Generic.IEnumerable`1[mvc3Post.Models.Contact]’.

controller:

    public ActionResult Index()
    {
        AdventureWorksEntities db = new AdventureWorksEntities();

        var result = from soh in db.SalesOrderHeaders
                     join co in db.Contacts
                     on soh.ContactID equals co.ContactID
                     orderby co.FirstName
                     group co by co.ContactID into g
                     select g;
        return View(result.AsEnumerable());
    }

view:

@model IEnumerable<mvc3Post.Models.Contact>
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            NameStyle
        </th>
        <th>
            Title
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.NameStyle)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ContactID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ContactID }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.ContactID })
            </td>
        </tr>
    }
</table>
  • 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-25T22:10:54+00:00Added an answer on May 25, 2026 at 10:10 pm

    Updated now that I see the controller method:

    You might need to transform your LINQ result set into a list or something (e.g., contacts.ToList()) more concrete.

    Another alternative might be to create a root object for your page’s list object to live on. I find it a little easier to follow and maintain if each View has a corresponding Model class that represents it’s entire state.

    I think either route will resolve your issue though. I think that the latter is probably the better way if I had to recommend one vs the other.

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

Sidebar

Related Questions

I am trying to display only selected items in list view. public class Mact
I'm trying to display a dropdown list of users in my view. Here is
Im trying to display this listview, but I keep getting a: 07-17 21:14:22.233: ERROR/AndroidRuntime(349):
I am trying to display the text from json in a list view. I
I am trying to create a list view which as TextView that can display
I have a list view that is displaying data using the gridview. This list
im trying to display items in a list view based on my raw query.
I am trying to display a list of task in this way - Icon
I am trying to display a list after clicking a button on Android. This
I am trying to display a list of all files found in the selected

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.