这是我的列表视图
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Year"
DataSourceID="AccountValueFundsDataSource" InsertItemPosition="LastItem">
........
</asp:ListView>
这是我的数据来源
<asp:SqlDataSource ID="AccountValueFundsDataSource" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:Life_InsuranceConnectionString %>"
DeleteCommand="DELETE FROM [AccountValueFunds] WHERE [Year] = @original_Year AND [avfcharge] = @original_avfcharge"
InsertCommand="INSERT INTO [AccountValueFunds] ([Year], [avfcharge]) VALUES (@Year, @avfcharge)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [AccountValueFunds]"
UpdateCommand="UPDATE [AccountValueFunds] SET [avfcharge] = @avfcharge WHERE [Year] = @original_Year AND [avfcharge] = @original_avfcharge">
<DeleteParameters>
<asp:Parameter Name="original_Year" Type="Int32" />
<asp:Parameter Name="original_avfcharge" Type="Decimal" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Year" Type="Int32" />
<asp:Parameter Name="avfcharge" Type="Decimal" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="avfcharge" Type="Decimal" />
<asp:Parameter Name="original_Year" Type="Int32" />
<asp:Parameter Name="original_avfcharge" Type="Decimal" />
</UpdateParameters>
</asp:SqlDataSource>
我的问题是如何验证输入?例如,如果用户输入的参数类型为十进制或整数??
答案 0 :(得分:0)
您可以使用RegularExpressionValidator - MSDN Article,RegularExpressionValidator - W3School处理该验证。
您需要ValidationExpression
允许decimal
和integer
但不允许string
。
检查这些
Accept only (0-9) integer and one decimal point(decimal point is also optional).
Regular Expression Validator - Numbers only no letters no spaces