Rishabh Singh

Rishabh Singh

  • NA
  • 10
  • 2.4k

category filters on the basis of search text.

Jun 12 2017 6:48 AM
My Controller is :-
ViewBag.categoryfilter = _context.MasterProductCategory.Include(u => u.MasterProduct).ThenInclude(u => u.Brand)
.Where(u => u.MasterProduct.ProductName.Contains(search)).ToList();
 
Where as MasterProduct is related with MasterProductCategory table on :-
public virtual ICollection<MasterProduct> MasterProduct { get; set; }
 
Hence  Under the Product Name Word it is showing Error. And In My view Page:-
@if (ViewBag.categoryfilter != null)
{
@foreach (var items in ViewBag.categoryfilter)
{
<li class="col-sm-3">
<a href="#" data-target="#@incval" data-toggle="collapse" data-parent="#stacked-menu">@items.CategoryName</a>
<ul class="nav nav-stacked collapse left-submenu col-sm-3" id="@incval">
@foreach (var item in ViewBag.categoryfilter)
{
<li class="pad-left-15"><a href="#">@item.BrandName</a></li>
}
</ul>
</li>
incval++;
}
}
 
These Are my codes to bind the category and respected brand on the basis of prodeuctname.
 
I am using VS2017 with asp.net-core Please Guide me with suitable solution to bind it properly. 

Answers (4)