Assistance with SQLDataSource Filtering with Mixed Control Types
<p>I have been looking into DataSource Filtering and the complexity of my page app is making my logic wade through mud. </p>

<p>I have a Gridview that Displays 3/17 Values from a Datasource.
I want to run a filter on 3 DropDowns and 3 Checkboxes against the datasource. The 3 DDLs have a default value of String.Empty at Index 0 and are populated by another DS on Page load (!IsPostBack).</p>

<p><strong>My Issues:</strong></p>

<ul>
<li>When the page loads there is nothing in the gridview. Empty DDL Values should be skipped. </li>
<li>The last check box should represent whether <strong>(Part_Catalog.PartCount > 0)</strong>. </li>
<li>Currently filters are defined in the datasource, but due to the above conditions I need to do some processing in the cs file. What I'm unsure of is If I need to move the Entire DS to the code behind, the filters, or just the filter conditions. </li>
<li><p>Also I'm not sure what events to wire into.</p>

<pre><code>&lt;asp:SqlDataSource ID="SqlDataSource1" 
     runat="server" 
     EnableCaching="true"
     DataSourceMode="DataSet"
     ConnectionString="&lt;%$ ConnectionStrings:inventory_v2ConnectionString %&gt;" 
                 SelectCommand="SELECT ID, OEMPartCode, PartCode2, UsedByOEM, ItemType, GroupType, PartCount, PartDesc, PartComment, PartMin, PartActive, MFRPartNumber, PartCapacity, PreTurnRequired, AssemblyPart, PartImage, PartImage2, NonInventoryPart FROM dbo.Part_Catalog"
                 FilterExpression="UsedByOEM = '{0}' AND ItemType = '{1}' AND GroupType = '{2}' OR     (UsedByOEM = '{0}' OR ItemType = '{1}' OR GroupType = '{2}') OR (UsedByOEM = '{0}' OR     ItemType = '{1}' AND GroupType = '{2}') OR (UsedByOEM = '{0}' AND ItemType = '{1}' OR     GroupType = '{2}')"&gt;
    &lt;FilterParameters&gt;
    &lt;asp:ControlParameter Name="UsedByOEM" ControlID="DDL_OEM" PropertyName="SelectedValue" /&gt;
    &lt;asp:ControlParameter Name="ItemType" ControlID="DDL_ItemTypes" PropertyName="SelectedValue" /&gt;
    &lt;asp:ControlParameter Name="GroupType" ControlID="DDL_GroupTypes" PropertyName="SelectedValue" /&gt;
    &lt;/FilterParameters&gt;    
&lt;/asp:SqlDataSource&gt;


  &lt;asp:DropDownList ID="DDL_OEM" runat="server" AutoPostBack="True" AppendDataBoundItems="True"&gt;&lt;/asp:DropDownList&gt;
   &lt;asp:DropDownList ID="DDL_ItemTypes" runat="server" AutoPostBack="True" AppendDataBoundItems="True"&gt;&lt;/asp:DropDownList&gt;   
   &lt;asp:DropDownList ID="DDL_GroupTypes" runat="server"   AutoPostBack="True" AppendDataBoundItems="True"&gt;&lt;/asp:DropDownList&gt;      
   &lt;asp:CheckBox ID="CheckBox1" runat="server" Checked="True" /&gt;
   &lt;asp:CheckBox ID="CheckBox2" runat="server" /&gt;
   &lt;asp:CheckBox ID="CheckBox3" runat="server" Checked="True" /&gt;

protected void BindOEMs()
{
    SqlConnection connectionString = new SqlConnection(ConfigurationManager.ConnectionStrings["inventory_v2ConnectionString"].ConnectionString);
    connectionString.Open();
    SqlCommand cmd = new SqlCommand("SELECT [Manufacturer], [ID] FROM [Models_OEMs] ORDER BY [Manufacturer]", connectionString);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    connectionString.Close();
    DDL_OEM.DataSource = ds;
    DDL_OEM.DataTextField = "Manufacturer";
    DDL_OEM.DataValueField = "ID";
    DDL_OEM.DataBind();
    DDL_OEM.Items.Insert(0, new ListItem(String.Empty, "0"));
}            
</code></pre></li>
</ul>
