TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Samir Bhogayta
674
1.4k
813.1k
Need solution for this error.
Dec 24 2019 3:31 AM
I am getting this error :
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType1`4[System.Int64,System.String,System.String,System.Int16]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Projectname.Models.user]'.
Here is my code of View
@model IEnumerable<Projectname.Models.user>
@{
ViewBag.Title =
"Index"
;
Layout =
"~/Views/Shared/_Layout.cshtml"
;
}
<h2>Index</h2>
<p>
@Html.ActionLink(
"Create New"
,
"Create"
)
</p>
<table
class
=
"table"
>
<tr>
<th>
@Html.Label(
"Email"
)
</th>
<th>
@Html.Label(
"First Name"
)
</th>
<th>
@Html.Label(
"Last Name"
)
</th>
<th>
@Html.Label(
"Status"
)
</th>
<th></th>
</tr>
@foreach (
var
item
in
Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.email)
</td>
<td>
@Html.DisplayFor(modelItem => item.first_name)
</td>
<td>
@Html.DisplayFor(modelItem => item.last_name)
</td>
<td>
@Html.DisplayFor(modelItem => item.status)
</td>
<td>
@Html.ActionLink(
"Details"
,
"Details"
,
new
{ id = item.id }) |
</td>
</tr>
}
</table>
This is my controller method
public
ActionResult Index()
{
var users = (from p
in
dBModels.users
join f
in
dBModels.auth_assignment.Where(x => x.item_name ==
"Customer"
)
on p.id equals f.user_id
select
new
{
id = p.id,
first_name = p.first_name,
last_name = p.last_name,
status = p.status
}).ToList();
return
View(users);
}
Kindly give proper answer to resolve this issue asap...
Reply
Answers (
9
)
Is eDiscovery analyst and Data analyst are same ?
Update And Upgrade difference