Gridview & Validation Controls

Discussion in 'ASP .Net Datagrid Control' started by Kat, Apr 9, 2007.

  1. Kat

    Kat Guest

    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>
     
    Kat, Apr 9, 2007
    #1
    1. Advertisements

  2. Kat

    Teemu Keiski Guest

    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)?
     
    Teemu Keiski, Apr 9, 2007
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...