简体   繁体   English

中继器内的范围验证器

[英]Range validator inside repeater

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) 空闲时间:20(最小10,最大40)

Pickup Time: 60 (min 3, max 90) 取车时间:60(最少3,最多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. 当显示页面时,它在文本框中显示“空闲时间”(标签)和20,嵌套行在文本框中显示“ Pickup Time”(标签)和60。 I need to prevent the user from entering 80 or 5 in Idle Time, but 80 or 5 is valid for Pcikup Time. 我需要防止用户在“空闲时间”中输入80或5,但是80或5对“ 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. 对于文本框“ tbValue”,我需要添加范围验证器,但是范围会根据我在转发器中显示的表的哪一行而变化。

(eg first item of repeater has "Idle Time" as globalconfigname and 20 as globalconfigvalue; next item has "Pickup Time" as globalconfigname and 60 as globalconfigvalue, ...) (例如,转发器的第一项具有“空闲时间”作为globalconfigname,而20具有作为globalconfigvalue;下一项具有“拾取时间”作为globalconfigname,而60具有作为“ globalconfigvalue”,...)

Thanks. 谢谢。

将数据绑定到RangeValidator控件上的MinimumValue和MaximumValue。

<asp:RangeValidator ControlToValidate="tbValue" MinimumValue='<%# Eval("MinValue") %>' MaximumValue='<%# Eval("MaxValue") %>' Type="Integer" Text="The value is not within the acceptable range!" runat="server" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM