Datagrid/Range Validator Error - Help Pls

V

VB Programmer

I am encountering a problem with my range validator in my datagrid.

I have the following column in my datagrid:

<ItemTemplate>
<asp:TextBox id=txtValue runat="server" Font-Size="XX-Small" Width="40px"
Text='<%# DataBinder.Eval(Container.DataItem, "Results") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
ControlToValidate="txtValue" ErrorMessage="All values are
required.">*</asp:RequiredFieldValidator>
<asp:RangeValidator id="RangeValidator" runat="server"
ControlToValidate="txtValue" ErrorMessage="*"
MinimumValue=0 MaximumValue=<%# DataBinder.Eval(Container.DataItem,
"MaxValue") %> Display="Dynamic"></asp:RangeValidator>
<asp:Label id="Label1" runat="server">
<%# DataBinder.Eval(Container.DataItem, "MaxValue") %>
</asp:Label>
</ItemTemplate>

I keep getting the following error, even though I do NOT have any MaxValues
less than 0!
Error: The MaximumValue cannot be less than the MinimumValue 0 of
RangeValidator.

Any ideas?
 
V

VB Programmer

I had to change it to a "number" comparison. Now the question is, can I put
an iif statement inline to handle nulls? Like this:
<asp:RangeValidator id="RangeValidator" runat="server"
ControlToValidate="txtValue" ErrorMessage="*"
MinimumValue=0 MaximumValue=<%# IIF(DataBinder.Eval(Container.DataItem,
"MaxValue")="",0,DataBinder.Eval(Container.DataItem, "MaxValue")) %>
Display="Static" Type="Integer"></asp:RangeValidator>
<asp:Label id="Label1" runat="server">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top