Click here to Skip to main content
15,909,835 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more: (untagged)
I have a customvalidator for textbox' in a gridview. The problem is, it doesn't fire up. I did put a break point to validation method but it never catches. The code is working fine in a single page with a single textbox but not in a GridView Can you please tell me what's wrong? Here's my code:

<asp:Content>

<script language="c#" runat="server">
      private void NumericControl(object sender, ServerValidateEventArgs args)
      {
            if (Tools.IsNumeric(args.Value))
                  args.IsValid = true;
            else
                  args.IsValid = false;
      }
</script>

<asp:GridView>
<Columns>
<asp:TemplateField>
                              <ItemTemplate>
                                    <asp:TextBox ID="txtValue" runat="server" Width="50" /><br />
                                    <asp:CustomValidator ControlToValidate="txtValue"
                                                            EnableClientScript="true"
                                                            ClientValidationFunction="NumericControl"
                                                            ErrorMessage="Not numeric"
                                                            OnServerValidate="NumericControl"
                                                            runat="server"
                                                            ValidationGroup="Kontor"
                                                            Display="Dynamic"
                                                            />
                              </ItemTemplate>
                        </asp:TemplateField>
</Columns>
</asp:GridView>


</asp:Content>
Posted

1 solution



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900