how to populate multiselect dropdown list with another dropdownlsit and apply filtering in three multiselect dropdown list .
How to create multiselect dropdownlist of checkbox
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Simran VermaRank #831 · 2.7K reputationPosted Oct 31, 2023, 7:34 AM EDT
FIrstly, You create a Model.
Like I have an example- You have a product with Id, name, and selected for track the state.
public class Product { public int Id { get; set; } public string Name { get; set; } public bool Selected { get; set; } }In a Controller create a list of products and you also used your databae if existed.
public IActionResult Index() { List products = new List { new Product { Id = 1, Name = "Product A" }, new Product { Id = 2, Name = "Product B" }, new Product { Id = 3, Name = "Product C" } }; return View(products); }Create a view, design depend on requirement where you will use html tag helpers, css also javascript for best user experience. All depends on your choice. for example, given a simple view code
@model List @for (var i = 0; i @Model[i].Name } SubmitAs your ques here I used checkbox. And at the end in your controller add the HTTP POST method to handle the response (for process the selected item)
[HttpPost] public IActionResult Index(List products) { var selectedProducts = products.Where(p => p.Selected).ToList(); // Perform your actions with the selected products return RedirectToAction("Index"); }