I keep getting an error saying that:
The model item passed into the dictionary is of type 'HomebaseSystemNew.Controllers.ProductRepository', but this dictionary requires a model item of type 'HomebaseSystemNew.Models.Product'
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<HomebaseSystemNew.Models.Product>" %>
My Repository:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using HomebaseSystemNew.Models; namespace HomebaseSystemNew.Controllers { public class ProductRepository { public Product GetProductID(int Pid) { DatabaseLinkedDataContext db = new DatabaseLinkedDataContext(); return db.Products.FirstOrDefault(ans => ans.Pid == Pid); } }
My Controller:
using System.Linq;using System.Web.Mvc;using HomebaseSystemNew.Models;namespace HomebaseSystemNew.Controllers { public class ProductsController : Controller { public ActionResult EditProduct(int id) { ProductRepository repo = new ProductRepository(); repo.GetProductID(id); return View(repo); } }