Why Join
Become a member
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
C# Corner Home
Technologies
MonthlyLeaders
ASK A QUESTION
Forumguidelines
chinedu Nwankwo
1.9k
94
20k
ASP,NET MVC View errors
Aug 17 2019 10:55 AM
Hello all please can you kindly help me out , i keep getting the error
The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[<>f__AnonymousType2`9[System.String,System.Nullable`1[System.Double],System.String,System.String,System.String,System.Nullable`1[System.DateTime],System.String,System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[LiberiaWaterBillingApplication.ViewModels.Building_Customer]'.
Here is my controller code
[HttpPost]
public
ActionResult searchpin1(
string
searchpin, LiberiaWaterBillingApplication.Models.BILLING_TABLE billmodel)
{
int
searchpinint = Convert.ToInt16(searchpin);
var CustomerVMlist = (from b
in
db1.BUI_TAB
join c
in
db1.CUS_TAB on b.CUS_ID equals c.CUS_ID
where b.PIN_NUM == searchpinint
select
new
{
b.NEW_TAR,
b.ASS_QTY,
b.ASS_UNI,
b.BUI_TYP,
c.ZON_NAM_NEW,
c.ZON_COD_NEW,
c.WAT_CON_STA,
c.SUR_NAM,
c.OTH_NAM
});
//if (pin_details == null)
// {
//billmodel.= " You have not enetered a Pinnmumber";
//}
// else
//{ }
return
View(CustomerVMlist.AsEnumerable());
}
This is my view code
@model IEnumerable<LiberiaWaterBillingApplication.ViewModels.Building_Customer>
@{
ViewBag.Title =
"Newsearch"
;
Layout =
"~/Views/Shared/_Layout.cshtml"
;
}
<h2>Newsearch</h2>
<html>
<head>
<title>Login</title>
<style>
#login-div {
position: absolute;
left: 40%;
top: 40%;
border: 1px solid #ccc;
padding: 10px 10px;
}
.field-validation-error {
color: red;
}
</style>
</head>
<body>
<div id=
"login-div"
>
@using (Html.BeginForm(
"searchpin1"
,
"DataEntry"
, FormMethod.Post))
{
<table>
<tr>
<td></td>
<td style=
"text-decoration:underline"
></td>
</tr>
<tr>
<td><input type=
"text"
name=
"pinsearch"
/></td>
</tr>
<tr>
<td></td>
<td><input type=
"submit"
name=
"submitbutton"
value=
"Login"
/><input type=
"reset"
name=
"resetbutton"
value=
"Reset"
/></td>
<td> </td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
}
</div>
<script src=
"~/Scripts/jquery-1.10.2.min.js"
></script>
<script src=
"~/Scripts/jquery.validate.min.js"
></script>
<script src=
"~/Scripts/jquery.validate.unobtrusive.min.js"
></script>
</body>
</html>
Thank you
Reply
Answers (
1
)
Form Athentication(mutliple contoller not working)
ekko-lightbox image marking and adding text in image.