我创建了下面的TextBox和CompareValidator,我认为它们可以允许以下形式的输入:
- 5
- 5.00
- $5.00
不幸的是,它不允许带有美元符号的版本。如果您不允许美元符号进行货币类型检查,那么这样做有什么意义呢?有没有一种方法可以允许这个符号?
<asp:TextBox ID="tb_CostShare" runat="server" Text='<%# Eval("CostShare", "{0:$0.00}")%>' CausesValidation="true" />
<asp:CompareValidator ID="vld_CostShare"
runat="server"
ControlToValidate="tb_CostShare"
Operator="DataTypeCheck"
Type="Currency"
ValidationGroup="vld"
ErrorMessage="You must enter a dollar amount for 'Cost Share'." />
{0:c}
呢? - Greg5.35
。如果你想要显示美元符号,可以在文本框前面放置一个标签。这样你也可以将其存储为 SQL 中的十进制数。 - Dustin Laine