title: ASP.NET issue setting CompareValidator.ValueToCompare
body: <p>I'm hoping someone can help. I've checked for an answer for this everywhere and can't find anything. I can't get my first if statement to "fire".</p>
  
  <p>In my form, I have a text box for a user to enter quantity, and I'm trying to validate it to 150 when it's a product with "Foil" and "Standard" or "Printed" and "Mini" in its subcategory name.  If it doesn't have any of those 4 words, then the minimum quantity should default to 250.  Here's my code for the "quantity" text box:</p>
  
  <pre><code>&lt;asp:TextBox ID="txtQuantity" runat="server" Text="Quantity" Width="300" /&gt;
  &lt;asp:RequiredFieldValidator ID="rfvQuantity" runat="server" ControlToValidate="txtQuantity" ErrorMessage="Quantity Required" Display="None" ValidationGroup="Quote" /&gt;
  &lt;asp:CompareValidator ID="cmvQuantity" runat="server" ControlToValidate="txtQuantity" ErrorMessage="Insufficient Quantity" Display="None" ValueToCompare="250" Operator="GreaterThanEqual" Type="Integer" ValidationGroup="Quote" /&gt;
  &lt;asp:CompareValidator ID="cmvQuantityText" runat="server" ControlToValidate="txtQuantity" ErrorMessage="Quantity Required" Display="None" Operator="DataTypeCheck" Type="Integer" ValidationGroup="Quote" /&gt;
  </code></pre>
  
  <p>And here's the code behind:</p>
  
  <pre><code>protected void rptProduct_ItemDataBound(object sender, RepeaterItemEventArgs e)
  {
      if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
      {
  
          ((CompareValidator)e.Item.FindControl("cmvQuantity")).ValueToCompare = ((Product)e.Item.DataItem).SubCategory.Category.Name.Contains("Foil") &amp;&amp; ((Product)e.Item.DataItem).SubCategory.Name.Contains("Standard") ? "150" : "250";
          ((CompareValidator)e.Item.FindControl("cmvQuantity")).ValueToCompare = ((Product)e.Item.DataItem).SubCategory.Category.Name.Contains("Printed") &amp;&amp; ((Product)e.Item.DataItem).SubCategory.Name.Contains("Mini") ? "150" : "250";
      }
  }
  </code></pre>
  
  <p>For some reason, it only seems to work for the last condition, not the first, even if I switch the position of the conditional statements, it still only works for the last statement and never the first.<br>
  So I'm thinking it's a semantic issue?
  Any help would be greatly appreciated!!
  Thanks!</p>