I've made two dropdown lists "Company" And "Product".
When I select the company, all its products appear in Product Dropdown list.
Now I want to do another work. If I select Company and product it will appear on below table list using jquery.
I was searching for the solution for last 3 days but can't find it so kindly please help me
Controller File
- [Authorize][AllowAnonymous]
- public ActionResult Details() {
- ViewBag.Companies = db.Companies.ToList();
- return View();
- }
- private IList < Product > GetProduct(int CompanyId) {
- var data = db.Products.Where(m =>m.CompanyId == CompanyId).ToList();
- return data;
- } [AcceptVerbs(HttpVerbs.Get)] public JsonResult LoadProductsByCompanyId(string CompanyId, string cn) {
- Cname = cn;
- var ProductList = this.GetProduct(Convert.ToInt32(CompanyId));
- var ProductsData = ProductList.Select(m =>new SelectListItem() {
- Text = m.ProductName,
- Value = m.ProductId.ToString(),
- });
- return Json(ProductsData, JsonRequestBehavior.AllowGet);
- }
View File
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Oct 12, 2020, 5:00 AM
Hamza ShahPosted Oct 12, 2020, 5:12 AM
Singh is king