Zeineb Mhiri

Zeineb Mhiri

  • NA
  • 17
  • 1.4k

Searching clients from database table

Apr 15 2017 11:35 AM
Hello i have a problem with button search in c#, it is not working (on web application).
here is my code in my controller "ClientController.cs":
public ActionResult GetAllClientDetails(string searchBy, string search)
{
ClientRepository ClientRepo = new ClientRepository();
ModelState.Clear();
if (searchBy == "Numero_compte")
{ return View(ClientRepo.GetAllClients().Where(X => X.Numero_compte == search).ToList()); }
else
{
return View(ClientRepo.GetAllClients().Where(X => X.Nom.StartsWith(search)).ToList());
}
}
and in my view which i called  "GetAllClientDetails.cshtml":

 

@using (Html.BeginForm("GetAllClientDetails","Client",FormMethod.Get))
{
Serach By : @Html.RadioButton("searchBy", "Numero_compte", true) Numero_compte
@Html.RadioButton("searchBy", "Nom") Nom
@Html.TextBox("Search")
}

 

I really can't understand what's the problem ... Help please. 

Answers (2)