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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:55:44+00:00 2026-05-26T23:55:44+00:00

I am new to MVC frame work. And i am making one page where

  • 0

I am new to MVC frame work. And i am making one page where we can see details of department by clicking on details link button.

While User click link button it fetch the all the records of the particular department in List Collection and redirect to Details View.Data has been fetched in List but while going to Details view it Generates following error:

The model item passed into the dictionary is of type ‘System.Collections.Generic.List1[DocPageSys.Models.Interfaces.DepartmentInfo]', but this dictionary requires a model item of type 'DocPageSys.Models.Interfaces.DepartmentInfo`’.

I understood the error but confusion to solve it.And stuck with this problem…

  • 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-26T23:55:44+00:00Added an answer on May 26, 2026 at 11:55 pm

    Since your Details view is strongly typed to DepartmentInfo:

    @model DocPageSys.Models.Interfaces.DepartmentInfo
    

    you need to pass a single instance of it from the controller action instead of a list:

    public ActionResult Details(int id)
    {
        DepartmentInfo depInfo = db.Departments.FirstOrDefault(x => x.Id == id);
        return View(depInfo);
    }
    

    So make sure that when you are calling the return View() method from your controller action you are passing a single DepartmentInfo instance that you have fetched from your data store.

    To make it run fine initially you could simply hardcode some value in it:

    public ActionResult Details(int id)
    {
        var depInfo = new DepartmentInfo
        {
            Id = 1,
            Name = "Sales",
            Manager = "John Smith"
        }
        return View(depInfo);
    }
    

    Oh, and you will notice that I didn’t use any ViewData/ViewBag. You don’t need it. Due to their weakly typed nature it makes things look really ugly. I would recommend you to always use view models.

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

Sidebar

Related Questions

I'm new to MVC and Entity frame work but i've come across an issue
I am new to MVC framework and here stucked with an updation method, can
total beginner to spring mvc. I need to prepopulate edit form in springmvc frame-work.
I am still very new to the MVC framework, but I managed to create
I am new to ASP.NET and the MVC framework as well, so I'd love
I'm rather new to MVC and as I'm getting into the whole framework more
I have started a new mvc project and clicked on project\properties\web - use local
I am new MVC user and I am trying to make shopping cart as
I've been doing alot of testing with my new MVC App and now I'm
Basically what the title says. I created a new MVC application. I'm trying to

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.