chinedu Nwankwo

chinedu Nwankwo

  • NA
  • 94
  • 27.9k

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
  1. [HttpPost]  
  2. public ActionResult searchpin1(string searchpin, LiberiaWaterBillingApplication.Models.BILLING_TABLE billmodel)  
  3. {  
  4. int searchpinint = Convert.ToInt16(searchpin);  
  5. var CustomerVMlist = (from b in db1.BUI_TAB  
  6. join c in db1.CUS_TAB on b.CUS_ID equals c.CUS_ID  
  7. where b.PIN_NUM == searchpinint  
  8. select new  
  9. {  
  10. b.NEW_TAR,  
  11. b.ASS_QTY,  
  12. b.ASS_UNI,  
  13. b.BUI_TYP,  
  14. c.ZON_NAM_NEW,  
  15. c.ZON_COD_NEW,  
  16. c.WAT_CON_STA,  
  17. c.SUR_NAM,  
  18. c.OTH_NAM  
  19. });  
  20. //if (pin_details == null)  
  21. // {  
  22. //billmodel.= " You have not enetered a Pinnmumber";  
  23. //}  
  24. // else  
  25. //{ }  
  26. return View(CustomerVMlist.AsEnumerable());  
  27. }  
This is my view code
  1. @model IEnumerable<LiberiaWaterBillingApplication.ViewModels.Building_Customer>  
  2. @{  
  3. ViewBag.Title = "Newsearch";  
  4. Layout = "~/Views/Shared/_Layout.cshtml";  
  5. }  
  6. <h2>Newsearch</h2>  
  7. <html>  
  8. <head>  
  9. <title>Login</title>  
  10. <style>  
  11. #login-div {  
  12. position: absolute;  
  13. left: 40%;  
  14. top: 40%;  
  15. border: 1px solid #ccc;  
  16. padding: 10px 10px;  
  17. }  
  18. .field-validation-error {  
  19. color: red;  
  20. }  
  21. </style>  
  22. </head>  
  23. <body>  
  24. <div id="login-div">  
  25. @using (Html.BeginForm("searchpin1""DataEntry", FormMethod.Post))  
  26. {  
  27. <table>  
  28. <tr>  
  29. <td></td>  
  30. <td style="text-decoration:underline"></td>  
  31. </tr>  
  32. <tr>  
  33. <td><input type="text" name="pinsearch" /></td>  
  34. </tr>  
  35. <tr>  
  36. <td></td>  
  37. <td><input type="submit" name="submitbutton" value="Login" /><input type="reset" name="resetbutton" value="Reset" /></td>  
  38. <td> </td>  
  39. </tr>  
  40. <tr>  
  41. <td></td>  
  42. <td></td>  
  43. </tr>  
  44. </table>  
  45. }  
  46. </div>  
  47. <script src="~/Scripts/jquery-1.10.2.min.js"></script>  
  48. <script src="~/Scripts/jquery.validate.min.js"></script>  
  49. <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>  
  50. </body>  
  51. </html>  
Thank you

Answers (1)