Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
[HttpPost]
        public ActionResult FilterByPara(Guid SubCategoryId, string BrandId , decimal Price1 = 0, decimal Price2 = 0, string SelPara = "")
        {
            try
            {
                if (BrandId != null && BrandId != "")
                {
                    Guid[] brand = BrandId.Split(',').Select(s => Guid.Parse(s)).ToArray();
                    var products = (from p in db.Products
                                    join sc in db.SubCategories
                                    on p.SubCategoryId equals sc.SubCategoryId
                                    where sc.SubCategoryId == SubCategoryId
                                    && p.Price >= Price1 && p.Price <= Price2
                                    && brand.Any(x => x == p.BrandId)  // p.BrandId.Contains(@brand) 
                                    select p).ToList();
                    ViewBag.Subid = SubCategoryId;
                    return View(products);
                    //
                }
                else
                {
                    var products = (from p in db.Products
                                    where p.SubCategoryId == SubCategoryId
                                    select p).ToList();
                    if (products.Count > 0)
                    {
                        ViewBag.Subid = SubCategoryId;
                        return View(products);
                    }
                    else
                    {
                        return RedirectToAction("Error", "Home");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //return Json(JsonRequestBehavior.AllowGet);
        }
Posted
Updated 8-Jun-15 19:59pm
v2

1 solution

You can add for example event on checkbox click. And then send your form, this will result in calling controller, process your data from form in that controller and based on that return your new view. ;)

So
1. add event on checkbox using for example jquery
2. send form

JavaScript
$("#mycheckbox").click(function(){
 $("#myForm").submit();
})


3. process data in contoller
C#
[HttpPost]
        public ActionResult FilterByPara(Guid SubCategoryId, string BrandId , decimal Price1 = 0, decimal Price2 = 0, string SelPara = "")



4. return view

C#
return View(products);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900