title: How to Implement Multiple search in Asp.Net
body: <p>I want to Implement multiple search query system in Asp.Net where search input are in form of TEXTBOX and DROPDOWN LIST. Query should work in combination or indivisually to filter the data from SQL Server
  and show in Gridview.</p>
  
  <p>This Code Snippet is for filtering two Dropdown values:</p>
  
  <pre><code>if (Agree_type_srch.SelectedValue != null || Status_srch.SelectedValue != null)
  {
      if (Agree_type_srch.SelectedValue != null)
      {
          string connString = @"data source=ABC; database=XYZ; user id=sa; password=1234;";
          SqlConnection conn = new SqlConnection(connString);
          SqlCommand com = new SqlCommand("Select *from EntryDatabase where Agree_type ='" + Agree_type_srch.SelectedItem.Text + "'", conn);
          SqlDataAdapter sqldatad = new SqlDataAdapter();
          DataSet ds = new DataSet();
  
          com.Connection = conn;
          sqldatad.SelectCommand = com;
  
          using (DataTable dt = new DataTable())
          {
              sqldatad.Fill(dt);
              GridView1.DataSource = dt;
              GridView1.DataBind();
          }
  
      }
      else if (Status_srch.SelectedValue != null)
      {
          string connString = @"data source=ABC; database=XYZ; user id=sa; password=1234;";
          SqlConnection conn = new SqlConnection(connString);
          SqlCommand com = new SqlCommand("Select *from EntryDatabase where Curnt_St ='" + Status_srch.SelectedItem.Text + "'", conn);
          SqlDataAdapter sqldatad = new SqlDataAdapter();
          DataSet ds = new DataSet();
  
          com.Connection = conn;
          sqldatad.SelectCommand = com;
  
          using (DataTable dt = new DataTable())
          {
              sqldatad.Fill(dt);
              GridView1.DataSource = dt;
              GridView1.DataBind();
          }
      }
  
      if (Agree_type_srch.SelectedItem.Text != null &amp;&amp; Status_srch.SelectedItem.Text != null)
      {
          string connString = @"data source=ABC; database=XYZ; user id=sa; password=1234;";
          SqlConnection conn = new SqlConnection(connString);
          SqlCommand com = new SqlCommand("Select * from EntryDatabase where Agree_type ='" + Agree_type_srch.SelectedItem.Text + "'and Curnt_St ='" + Status_srch.SelectedItem.Text + "'", conn);
          SqlDataAdapter sqldatad = new SqlDataAdapter();
          DataSet ds = new DataSet();
  
          com.Connection = conn;
          sqldatad.SelectCommand = com;
  
          using (DataTable dt = new DataTable())
          {
              sqldatad.Fill(dt);
              GridView1.DataSource = dt;
              GridView1.DataBind();
          }
      }
  ...
  </code></pre>