How to perform searching operation use dropdownlistin mvc 5
how to perform searching operation use multiple dropdownlist in mvc 5 for hotel search and booking
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Jan 22, 2015, 10:21 PM EST
Can you be more specific with your requirement. According to my understanding, it seems that you have multiple dropdown and want to get the selected values of all, on click of Search button at actionmethod.
Here one way I can suggest is if your name attribute of all dropdown is available as a paramter of you AcitionMethod then yours selected value in dropdown will be avialable to you parameter.
//View
@using (Html.BeginForm("Search", "Home"))
{
@Html.DropDownList("D1", new List
,new SelectListItem(){ Text = "B", Value = "B" }});
@Html.DropDownList("D2", new List
,new SelectListItem(){ Text = "DEF", Value = "2" } });
}
----------------------------------------------------------
//Action Method
public ActionResult Search(string D1, string D2)
{
//Code here
return View();
}
Now D1, D2 parameter will have respective selected value
Plz mark it as answered if it solves your problem. I just created as demo sample to convey how it works
Bhushan GawaleRank #299 · 8.4K reputationPosted Jan 22, 2015, 10:27 PM EST
You can also make use of Json and send the Json object to the controller if there are many search criteria are involved.