本文介绍了如何在CheckBoxClick上调用MVC控制器并重定向到View的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 [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); } 推荐答案 3.控制器中的处理数据 3. process data in contoller[HttpPost] public ActionResult FilterByPara(Guid SubCategoryId, string BrandId , decimal Price1 = 0, decimal Price2 = 0, string SelPara = "") 4.返回视图 4. return view return View(products); 这篇关于如何在CheckBoxClick上调用MVC控制器并重定向到View的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 12:19