title: ASP.NET SqlDataSource, like on SelectCommand
body: <p>I'm working on asp.net.  I Have a <code>SqlDataSource</code> with a query hardcoded on selectcommand:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="DataSource1" runat="server" CancelSelectOnNullParameter="False"
      ConnectionString="&lt;%$ ConnectionStrings:S.Properties.Settings.ConnectionString %&gt;" 
      SelectCommand="SELECT * FROM [table]
      WHERE ([col1] like Case @col1_param When null Then col1 Else @col1_param End)
      and  ([col2] like Case @col2_param When null Then col2 Else @col2_param End)"
      SelectCommandType="Text"&gt;
      &lt;SelectParameters&gt;
          &lt;asp:ControlParameter ControlID="TextBox1" Name="col1_param" PropertyName="Text"
              Type="String" /&gt;
          &lt;asp:ControlParameter ControlID="TextBox2" Name="col2_param" PropertyName="Text"
              Type="String" /&gt;
      &lt;/SelectParameters&gt;
  </code></pre>
  
  <p>What I want is that if you enter data on one textbox only, the data will display according with that textbox value only on the where clause. And if no values are placed for neither of the textboxes, the the query executes as if there is no where.</p>
  
  <p>Right now with this code,what happens is if you put on one textbox only no data is displayed. The same if all textboxes are empty.</p>
  
  <p>I don't want to use sql stored procedure. </p>
  
  <p>How can I solve this?</p>
  
  <p>Thanks...</p>