I have an ASP Label which shows the total number of items in an inventory system that is available for requisitions.
I am working on a way to check the value entered in a TextBox is less than or equal to the number in the Label, which is loaded from an ORACLE database.
I created a RangeValidator but am having trouble with setting the MaximumValue to the contents of the Label. I initially tried to use the Label ID for the parameter but as I understand it, it doesn't work because the two controls are not compatable so I tried to use an expression to get the Text property from the Label but am getting type casting exceptions.
I think I'm on the right track but can't find anything via Google.
Any ideas?
I am working on a way to check the value entered in a TextBox is less than or equal to the number in the Label, which is loaded from an ORACLE database.
I created a RangeValidator but am having trouble with setting the MaximumValue to the contents of the Label. I initially tried to use the Label ID for the parameter but as I understand it, it doesn't work because the two controls are not compatable so I tried to use an expression to get the Text property from the Label but am getting type casting exceptions.
Code:
<asp:TextBox Width="50px" ID="txtQuantity" runat="server">0</asp:TextBox>
<asp:RangeValidator Display="Dynamic"
MinimumValue="0" MaximumValue="<%lblAvailableQuantity.text %>"
Type="string" ControlToValidate="txtQuantity"
ErrorMessage="Quantity is greater than Available"
runat="server">*</asp:RangeValidator>
<asp:Label ID="lblAvailableQuantity" runat="server"></asp:Label>
I think I'm on the right track but can't find anything via Google.
Any ideas?