Gridview & Validation Controls


K

Kat

How do I get the RegularExpressionValidator to work with a gridview during
an update? The error message displays briefly -- very briefly, you don't
even see it unless you are stepping through the code, but the update
continues as if nothing happened. If I have to use the RowUpdating event,
then what's the purpose of the validator? It appears the
requiredfieldvalidator works, but not the regularexpressionvalidator. This
is my gridview template:

<asp:TemplateField HeaderText="Preferred">

<EditItemTemplate>

<asp:TextBox ID="txtPreferredPhone" runat="server" Text='<%#
Bind("PhoneNumber") %>' ></asp:TextBox>

<asp:RegularExpressionValidator ControlToValidate="txtPreferredPhone"
id="valPhoneNumbers" runat="server" ErrorMessage="Please use phone number
format (111-111-1111)" ToolTip="111-111-1111"
ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"
ValidationGroup="PhoneNumberValidator" Display="Dynamic">Incorrect
format!</asp:RegularExpressionValidator>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Bind("[Preferred #]")
%>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>
 
Ad

Advertisements

T

Teemu Keiski

Hi,

do you also do Page.IsValid check in code (yes it needs to be done in order
to ensure nothing passes server-side validation)?

Does the regexvalidator catch the error at client-side at all? (Do you have
ValidationSummay on the Page and does it show anything)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top