0

I have a repeater that displays key-value pairs from a database table. Some of the fields in the table have min/max restriction. How can I add a range validator to the repeater and be able to use different ranges for different fields?

For example, some table fields are:

Idle Time: 20 (min 10, max 40)

Pickup Time: 60 (min 3, max 90)

When page is displayed it shows "Idle Time" (a label) and 20 in a text box, the nest row is "Pickup Time" (a label) and 60 in the textbox. I need to prevent the user from entering 80 or 5 in Idle Time, but 80 or 5 is valid for Pcikup Time.

<ItemTemplate> <tr> <td style="vertical-align:top" class="BoldSmall"> <asp:Label runat="server" ID="lblName" Text='<%# Eval("GLOBALCONFIGNAME")%>' /> </td> <td style="vertical-align:top" class="BoldSmall"> <asp:TextBox runat="server" ID="tbValue" CssClass="NormalSmall" Text='<%# Eval("GLOBALCONFIGVALUE")%>' Width="140" /> </td> </tr> </ItemTemplate> 

For textbox "tbValue" I need to add range validator, but the range change depending on what row of the table I am displaying in the repeater.

(e.g. first item of repeater has "Idle Time" as globalconfigname and 20 as globalconfigvalue; next item has "Pickup Time" as globalconfigname and 60 as globalconfigvalue, ...)

Thanks.

2
  • 1
    i think seeing code would benefit us Commented Jul 31, 2013 at 20:02
  • Just edited original question. Commented Jul 31, 2013 at 20:39

1 Answer 1

1

Databind to MinimumValue and MaximumValue on the RangeValidator control.

<asp:RangeValidator ControlToValidate="tbValue" MinimumValue='<%# Eval("MinValue") %>' MaximumValue='<%# Eval("MaxValue") %>' Type="Integer" Text="The value is not within the acceptable range!" runat="server" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.