title: how to Filter webgrid in mvc4 based on textbox input and dropdownList input
body: <p>I am still in learning curve of mvc4 . I know how to bind a webgrid in mvc4 . But my doubt is can anyone share me the idea how to bind webgrid based on filter conditions from textbox input and  dropdownList input. For eg : If textbox has a date "11/15/2013" and dropdownList has the doctor name "Charles" then i need to show in gridview the list of patients who has appointment with doctor " charles " on "11/15/2013" . </p>
  
  <p>code </p>
  
  <pre><code> &lt;div id="gridContent"&gt;
   @grid.GetHtml(
   fillEmptyRows: true,
   tableStyle: "webGrid",
   alternatingRowStyle: "alternate-row",
   headerStyle: "grid-header",
      footerStyle: "grid-footer",
      mode: WebGridPagerModes.All,
       firstText: "&lt;&lt; First",
      previousText: "&lt; Prev",
       nextText: "Next &gt;",
      lastText: "Last &gt;&gt;",
      columns: new[] {        
      grid.Column("PatientID"),
      grid.Column("PatientName"),
      grid.Column("Age"),
      grid.Column("DOB"),
      grid.Column("Sex"),
      grid.Column("Phone"),
      grid.Column("Mobile"),
      grid.Column("City"),
      grid.Column("PinCode"),
  
     // grid.Column("Dr_Remarks",header:"Remarks",style:"left"),
  
  
      //grid.Column("Dr_Add1", 
      //            header: "Bed Count",style:"right"
      //),
  
      grid.Column("", 
                  header: "Actions",
                  format: @&lt;text&gt; 
      @Html.ActionLink("Edit", "EditPatient", new { id = item.PatientID }, htmlAttributes: new { @class = "link" })
      |
      @Html.ActionLink("Delete", "PatientList", new { id = item.PatientID },
               htmlAttributes: new { @class = "link", onclick = "return confirm('Are you sure you wish to delete this record?');" })
       &lt;/text&gt;
      )
    })
    &lt;/div&gt;
  
  
      **controller**
  
          public ActionResult PatientList(int page = 1, string sort = "Dr_Id", string sortDir = "ASC", int id = 0)
      {
          if (id != 0)
          {
              bool isDelete = false;
              isDelete = rdm_Patient.DeletePatient(id);
  
  
              return View(GetPatient(page, sort, sortDir));
          }
          else
          {
              return View(GetPatient(page, sort, sortDir));
          }
      } 
  
       private PatientPageViewModel GetPatient(int page = 1, string sort = "Dr_Id", string sortDir = "ASC")
      {
          const int patientPerPage = 5;
          var numPatient = rdm_Patient.CountPatient();
          sortDir = sortDir.Equals("desc", StringComparison.CurrentCultureIgnoreCase) ? sortDir : "asc";
          var validColumns = new[] { "PatientID", "PatientName" };
          if (!validColumns.Any(c =&gt; c.Equals(sort, StringComparison.CurrentCultureIgnoreCase)))
              sort = "PatientID";
          var doctors = rdm_Patient.getpatientpage(page, patientPerPage, "it." + sort + " " + sortDir);
          var data = new PatientPageViewModel()
          {
  
              numberOfPatient = numPatient,
              patientPerPage = patientPerPage,
              Patient = doctors,
          };
          return data;
      }
  </code></pre>