如何在按钮单击时对 RangeValidator1 进行硬编码,以根据所查看产品的特定类型执行不同的操作,例如:
if(id == 1)
{
RangeValidator1.Enabled = true;
RangeValidator1.Type = ValidationDataType.Integer;
RangeValidator1.MaximumValue = "6";
RangeValidator1.MinimumValue = "1";
RangeValidator1.ErrorMessage = "Only 6 allowed per customer";
}
else if(id == 2)
{
RangeValidator1.Enabled = true;
RangeValidator1.Type = ValidationDataType.Integer;
RangeValidator1.MaximumValue = "10";
RangeValidator1.MinimumValue = "1";
RangeValidator1.ErrorMessage = "Only 10 allowed per customer";
}
else
RangeValidator.Enabled = false;
这是我想要在单击按钮时实现的一般要点,但它引发了关于“无法将 MaximumValue 属性 RangeValidator1 的值”转换为 Integer 类型的错误。
帮助?