hi
I use 2 Textboxs for searching Items in database :
HTML-
<div class="form inline">
@using (Ajax.BeginForm("Search", "Test", new AjaxOptions { HttpMethod = "Post",
InsertionMode = InsertionMode.Replace, LoadingElementId = "imgLoading", LoadingElementDuration
= 1000, Url = "/Test/Search", UpdateTargetId = "divSearch" })) {
<div class="group">
@Html.Label("جستجو روی نام", new { @class = "label" })
<div class="controls">
@Html.TextBox("txtSearchName", null, new { @class = "text", style = "width: 240px;"
})
</div>
</div>
<div class="group">
@Html.Label("جستجو روی آدرس", new { @class = "label" })
<div class="controls">
@Html.TextBox("txtSearchAddress", null, new { @class = "text", style = "width: 240px;"
})
</div>
</div>
</div>
and:
Code -
public ActionResult Search(string txtSearchName, string txtSearchAddress)
{
System.Threading.Thread.Sleep(2000);
var blReseller = new ResellerRepository();
var model = blReseller.Where(p => p.Name.Contains(txtSearchName) && p.Address.Contains(txtSearchAddress)).ToList();
return PartialView("_SearchReseller", model);
}
as you see in above action I use txtSearchName and txtSearchAddress (2 textbox's Id) for searching data in database
now I want define DropdownList that users can select Item from Dropdownlist and click button to search in database below is code:
<div>
<div class="form inline">
@using (Ajax.BeginForm("Search", "Test", new AjaxOptions { HttpMethod = "Post",
InsertionMode = InsertionMode.Replace, LoadingElementId = "imgLoading", LoadingElementDuration
= 1000, Url = "/Test/Search", UpdateTargetId = "divSearch" })) {
<div class="group">
@Html.Label("جستجو روی نام", new { @class = "label" })
<div class="controls">
@Html.DropDownListFor(model => model.Ostans, Model.Ostans1, "Please select")
</div>
</div>
<div class="group">
@Html.Label("جستجو روی آدرس", new { @class = "label" })
<div class="controls">
@Html.DropDownListFor(model => model.Citeies1, Model.Citeies1, "Please select")
</div>
</div>
<div class="block-standart">
<div class="form">
<div class="group">
<div class="controls">
<img src="~/Content/Images/loading (1).gif" id="imgLoading" style="display: none" />
<button class="button">
جستجو</button>
</div>
</div>
</div>
</div>
</div>
</div>
} @Html.Partial("_SearchReseller", Model)
now I want in ACTION use DropDownList Selected Item and search in database how I can use it in below action
public ActionResult Search(string txtSearchName, string txtSearchAddress)
{
System.Threading.Thread.Sleep(2000);
var blReseller = new ResellerRepository();
var model = blReseller.Where(p => p.Name.Contains(txtSearchName) && p.Address.Contains(txtSearchAddress)).ToList();
return PartialView("_SearchReseller", model);
}
best regards
Neda