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

  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
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "Kat" <> wrote in message
    news:...
    > 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>
    >
    >
    >
    >
    Teemu Keiski, Apr 9, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    14
    Views:
    4,076
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  2. =?Utf-8?B?ZGh1cndpdHo=?=
    Replies:
    1
    Views:
    446
    Teemu Keiski
    Apr 10, 2004
  3. baroque Chou
    Replies:
    4
    Views:
    426
    Peter Blum
    Jan 24, 2006
  4. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,947
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  5. AlBruAn

    GridView and Validation Controls

    AlBruAn, Oct 10, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    220
    AlBruAn
    Oct 10, 2007
Loading...

Share This Page