Filtering DataGrid using DropDown
<p>I am trying to filter my databound datagridview by CompanyID using an updatepanel. For some reason it's not working. Here's my code. Thanks for your help!</p>

<p>C#</p>

<pre><code>string company_id;

protected void Page_Load(object sender, EventArgs e)
{

        SqlCommand cmd = new SqlCommand("SELECT CompanyName, CompanyID FROM Company ORDER BY CompanyName", conn);
        SqlCommand cmd2 = new SqlCommand("SELECT p.ProjectName AS ProjectName, p.ProjectID, p.CompanyID, p.Status AS Status FROM Project p, Company c WHERE p.CompanyID = c.CompanyID AND c.CompanyID = '" + company_id + "' ORDER BY ProjectName", conn);

        cmd.CommandType = CommandType.Text;

        SqlDataAdapter da = new SqlDataAdapter(cmd);

        DataSet ds = new DataSet();

        da.Fill(ds);

        if (!Page.IsPostBack)
        {
            company_list.DataSource = ds;
            company_list.DataTextField = "CompanyName";
            company_list.DataValueField = "CompanyID";
            company_list.DataBind();

            company_list.Items.Insert(0, new System.Web.UI.WebControls.ListItem("-- Please Select Company --"));


        //cmd2.Connection.Open();

            cmd2.CommandType = CommandType.Text;

            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd2);
            DataSet ds2 = new DataSet();
            sqlAdapter.Fill(ds2);

            Gridview1.DataSource = ds2;
            Gridview1.DataBind();

            conn.Close();
        }

        //cmd2.Connection.Close();
        //cmd2.Connection.Dispose();
    }

}
protected void company_list_SelectedIndexChanged(object sender, EventArgs e)
{

    company_id = company_list.SelectedValue;

}
</code></pre>

<p>ASP.NET:</p>

<pre><code>&lt;asp:DropDownList ID="company_list" runat="server" 
                             onselectedindexchanged="company_list_SelectedIndexChanged" width="175" AutoPostBack="true" /&gt;
</code></pre>

<p>...</p>

<pre><code>&lt;asp:UpdatePanel ID="UpdateGrid" runat="server"&gt;
                &lt;ContentTemplate&gt;
                           &lt;asp:gridview ID="Gridview1" runat="server" ShowFooter="True"
                       AutoGenerateColumns="False" GridLines="None"&gt;
....

                &lt;/ContentTemplate&gt;
                &lt;Triggers&gt;
                    &lt;asp:AsyncPostBackTrigger ControlID="company_list" /&gt;
                &lt;/Triggers&gt;
 &lt;/asp:UpdatePanel&gt;
</code></pre>
