filter syntax where some items may or may not be selected : <p>I've got 3 dropdown boxes on my asp.net form: Country, State and City.  I want to use these to filter my data.  However, I also want the user to have the ability to not use the filters, or not use <em>all</em> the filters.</p>

<p>For instance, they may not want to filter at all.  Or they may only want to filter by Country.  Or only by Country/State.  Or, if it's not the US, then by Country/City.</p>

<p>I'm stuck on how to write this.  Right now I have:</p>

<pre><code> SqlDataAdapter adapter = new SqlDataAdapter("Select * from [MOS_Role] where [Country_ID] = @CoID AND [State_ID] = @StID AND [City_ID] = @CiID ORDER BY [Role] ASC", con2);
 adapter.SelectCommand.Parameters.AddWithValue("@CoID", Convert.ToInt32(ddlCountry.SelectedValue));
 adapter.SelectCommand.Parameters.AddWithValue("@StID", Convert.ToInt32(ddlState.SelectedValue));
 adapter.SelectCommand.Parameters.AddWithValue("@CiID", Convert.ToInt32(ddlCity.SelectedValue));
</code></pre>

<p>but that doesn't work when you leave a dropdown unselected.</p>
