title: Using case with operators ( =, LIKE)
body: <p>I have a scenario where I want to run the query by selecting value from dropdownlist which consist of <code>=</code> and <code>LIKE</code>.</p>
  
  <p>Here is the html:-</p>
  
  <pre><code> &lt;td valign="left" width="20%"&gt;
                      &lt;asp:DropDownList ID="ddlmathsign" runat="server" Style="width: 30%; background-repeat: no-repeat;
                          background-position: bottom right; border: solid 1px #ACACAC; font-family: Tahoma,Arial,Helvetica,Geneva,sans-serif"&gt;
                          &lt;asp:ListItem Value="Equal"&gt;=&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Value="LIKE"&gt;LIKE&lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
  </code></pre>
  
  <p>i want a query for <code>Current_Item_Batch</code> on the basis of operators user selects from the list.</p>
  
  <pre><code>select * from WMS_BIN_STATUS_TRACK where location_name='A1132' or Current_Item_code='4059010' or (CASE WHEN Current_Item_Batch = 'what query should come here ???'
  </code></pre>
  
  <p>I tried with <code>case</code> with below query but it didn't worked for me</p>
  
  <pre><code>"select * from WMS_BIN_STATUS_TRACK where " +
                       "location_name='" + ddlBin.SelectedValue + "' or Current_Item_code='" + ddlItem.SelectedValue + "' or "+
                       "(CASE WHEN Current_Item_Batch = " + ddlmathsign.SelectedValue + " then Current_Item_Batch='" + txtBatch.Text + "'";
  </code></pre>
  
  <p>Please suggest what is going wrong here</p>
  
  <p>I am using <strong>SQL server 2005</strong></p>