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 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions01ForumsTop experts
Arun PottiAnswers in the forums20answers02
Tahir AnsariAnswers in the forums5answers03
Kamlesh KumarAnswers in the forums5answers04
Sam HobbsAnswers in the forums4answers05
Željko PerićAnswers in the forums3answersFull leaderboard →
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Oct 12, 2020, 1:00 AM EDT
Hamza Shah86 reputationPosted Oct 12, 2020, 1:12 AM EDT
Singh is king