With two controls on your asp.net page a DropDownList (ID ddlDropDownList) and a GridView (ID gvGridView), to retrieve the SelectedValue from the DropDownList and use that in the where clause of the query used to bind data to your GridView the following will help.

Required using statements

[codesyntax lang=”csharp”]
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
[/codesyntax]

ADO.NET block of code to base your bind on using an SQLDataAdapter so you can still have paging on the GridView.

[codesyntax lang=”csharp”]

    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CONNSTRINGNAME"].ConnectionString))
    {
      using (SqlCommand cmdGrid = new SqlCommand("SELECT * FROM TABLE WHERE FIELD = @PARAMETER", con))
      { 
      cmdGrid.Parameters.AddWithValue("@PARAMETER", ddlDropDownList.SelectedValue);
      con.Open();

      using (SqlDataAdapter da = new SqlDataAdapter(cmdGrid))
      {
        DataTable dt = new DataTable();
        da.Fill(dt);           
        gvGridView.DataSource = dt;
        gvGridView.DataBind();
      }
      }
    }

[/codesyntax]

The structure of the code is with using statments to ensure the garbage collection is carried out efficiently.