I am new to asp.net MVC. I have two tables named as Category and Product. Product table has foreign key which CategoryID. I am able to display category on a page. Lets take one example. I have two categories named Mobiles and Computers. When I click in Computer, I would like to display products related to Computer Category.
I have attached codes. Kindly, help me with this.
public ActionResult ProductList(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Products.Find(id);
if (product == null)
{
return HttpNotFound();
}
return View(product);
}
Here is model: @model IEnumerable<ReSale.Models.Product>
I am using IEnumerable. I am getting above error.