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.
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.
Bhushan GawalePosted Jan 23, 2015, 3:27 AM
You can also make use of Json and send the Json object to the controller if there are many search criteria are involved.
Pradeep ShetPosted Jan 23, 2015, 3:21 AM
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