In a GridView template field, I have a textbox in an ItemTemplate and Compare validator directly below it (checking that an integer was entered). Underneath the grid I have a ValidationSummary. If I enter a non-integer in the textbox, the ErrorMessage displays within the CompareValidator in the grid, instead of showing on the ValidationSummary. Here's my code:
And for the ValidationSummary:
Code:
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:TextBox Text='<%# Bind("Quantity") %>' onChange='EnableEntrySave()'
Width="100%" ID="txtQuantity" runat="server">
</asp:TextBox>
<asp:CompareValidator ID="valQtyNumeric" runat="server" ControlToValidate="txtQuantity"
Display="Dynamic" SetFocusOnError="true" Text="" ErrorMessage="Error: Qty must be a number!" Operator="DataTypeCheck" Type="Integer">
</asp:CompareValidator>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
And for the ValidationSummary:
Code:
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
EnableViewState="False" Width="100%" />