Powie mi ktoś dlaczego mam błąd kompilacji ?
Chodzi o linijkę
@Html.DropDownList("categories", "Wybierz kategorię", new { onchange = "CallChangefunc(this.value)" })
@using Sklep.Models;
@Styles.Render("~/Content/css")
@{
ViewBag.Title = "Home Page";
}
<div class="wrapper">
<div class="dropdown_list">
@Html.DropDownList("categories", "Wybierz kategorię", new { onchange = "CallChangefunc(this.value)" })
</div>
<div class="gallery">
<h3 class="underline">Wszystkie produkty</h3>
@foreach (var product in ViewBag.products)
{
<div class="gallery__item">
<p>@product.ProductName</p>
<img src="~/Img/@product.ProductImage" alt="No image" />
<p>@product.ProductPrice zł</p>
<p>@product.ProductDescription</p>
</div>
}
</div>
</div>
<script>
function CallChangefunc(val) {
window.location.href = "/Home/Index?category=" + val;
}
</script>
public class HomeController : Controller
{
private DatabaseContext db = new DatabaseContext();
public ActionResult Index()
{
using (var context = new DatabaseContext())
{
ViewBag.categories = new SelectList(db.Categories.SqlQuery("[dbo].[getCategory]"), "CategoryID", "CategoryName");
}
using (var context = new DatabaseContext())
{
var data = context.Products.SqlQuery("[dbo].[getProducts]").ToList();
ViewBag.products = data;
}
return View();
}