我正在尝试为控件中RegularExpressionValidator
的文本框添加一个。EditItemTemplate
GridView
当用户点击“更新”时,如果输入错误,验证器工作(错误信息可见)。但是,在OnRowUpdating
方法上,我有Page.IsValid==true
. 为什么会这样?
ASP 代码:
<asp:GridView ID="dgvsaldoPV" runat="server" Visible="False" AutoGenerateColumns="False"
ShowFooter="True" AllowSorting="True" OnSorting="TaskGridView_SortingSaldoPV" OnRowEditing="gv1_RowEditing"
OnRowUpdating="gv1_RowUpdating" onRowCancelingEdit="gv1_RowCancelingEdit" DataKeyNames="ID_CASSA">
<AlternatingRowStyle BackColor="#FFFFCC" />
<Columns>
<asp:TemplateField HeaderText="Saldo" InsertVisible="False" SortExpression="SALDO" >
<EditItemTemplate >
<asp:TextBox ID="txtsaldo" runat="server" validationgroup="saldo" Text='<%# Bind("SALDO") %>'></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtsaldo"
ErrorMessage="Inserisci valori numerici, usare ',' per i decimali" ValidationExpression="^\d*\,?\d+$" validationgroup="saldo"
ForeColor="Red" ></asp:RegularExpressionValidator>
</EditItemTemplate>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<%# Bind("SALDO") %>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="style11" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowHeader="false" HeaderStyle-CssClass="headerstyle1"/>
</Columns>
<FooterStyle BackColor="#CC0000" ForeColor="White" />
<HeaderStyle CssClass="headerstyle" />
<RowStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
</asp:GridView>