如何在列表视图中验证输入?

时间:2012-06-11 06:51:40

标签: asp.net

这是我的列表视图

<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>

我的问题是如何验证输入?例如,如果用户输入的参数类型为十进制或整数??