title: How to programatically set the Maximum Value on a Range Validator?
body: <p>I want to set a Range Validator on a text box to prevent someone from ordering more of a product than is available. I have the amount available stored in a database and I databound the maximum value property of the Ranged Validator to the field in the database.</p>
  
  <pre><code>&lt;asp:RangeValidator ID="RangeValidator1" runat="server" 
                      ControlToValidate="tbQuantity" Display="Dynamic" ErrorMessage = "Can't Order More Than Quantity." 
                      ForeColor="Red" MaximumValue='&lt;%# Eval("Quantity") %&gt;' MinimumValue="0"&gt;&lt;/asp:RangeValidator&gt;
  </code></pre>
  
  <p>However when I debug the program I get some unexpected results.</p>
  
  <p>The quantity is 17. 
  and 1 does not trigger the error message, but 2-9 does and 10-17 doesn't trigger it but 18 and up do. I'm guessing this has something to do with the fact that it is comparing strings but I'm not sure how to change it to comparing numbers.</p>