iam using mvc3,i have empty search form in that am using only textbox with search button,if user search for data and click search button,then it has to show the result which is taken from index view. Here is my controller action
public ActionResult Search(string searchString)
{
var certificate = from s in db.certificate_mst
select s;
if (!String.IsNullOrEmpty(searchString))
{
certificate = certificate.Where(s => s.CertificateNo.Contains(searchString));
}
return View(certificate);
}
and my view code is
@using (Html.BeginForm("Search","certificate1",FormMethod.Get))
{
<p><b>CertificateNo</b>:@Html.TextBox("searchString")
<input type="submit" value="search" />
By using this code,searching is working but am getting all the data which i have in my view before searching,i need to have empty form before click search button and only after i click search it has to show result.