List groups are flexible components that either display simple lists of elements or can be combined with other elements to create complex lists with custom content. Our search will redirect us to the SearchProductsResult
view when the user searches for products. This view uses a list group to display the product items found. The method that retrieves the products from the database is as follows:
public ActionResult SearchProductsResult(string query) { ViewBag.SearchQuery = query; var results = _context.Products.Where(p => p.ProductName.Contains(query)).ToList(); return View(results); }
The Razor markup for the view represents the following:
@model IEnumerable<Northwind.Data.Models.Product> @{ ViewBag.Title = "Product Search Results"; Layout = "~/Views/Shared/_Layout.cshtml"; } <div class="container"> <div class="page-header"> <h1>Product Results <small>Results for your search term: "@ViewBag.SearchQuery"</small...