Click here to Skip to main content
11,638,881 members (75,024 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET validation
hi i have gridview ,i want to validate all the field inside gridview

my grid view as
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                                                    Font-Names="Tahoma" Font-Size="11px"
                                                                                    HeaderStyle-CssClass="HeaderStyle" HorizontalAlign="Left"
                                                                                    <%--<RowStyle BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" ForeColor="Blue"
                                                            Wrap="True" />--%>
                       ShowEditButton="True" CausesValidation="true" ValidationGroup="ValGrpEdit"></asp:CommandField>
                                                                                        <asp:TemplateField ShowHeader="False">
                                                                                                <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" 
                                                                                                    CommandName="Delete" Text="Delete"></asp:LinkButton>
                                                                                        <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                                                                                <asp:TextBox ID="Name1" runat="server" CssClass="text" Text='<%# Bind("Name") %>'
                                                                                                <asp:RequiredFieldValidator ID="RequiredName" runat="server" ControlToValidate="Name1"
                                                                                                    ErrorMessage="Please enter a valid Name."  EnableClientScript="true" ValidationGroup="ValGrpEdit" Width="16px">*</asp:RequiredFieldValidator>
                                                                                                <asp:Label ID="Name2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                                                                            <ItemStyle ForeColor="Black" Width="15%" />
                                                                                            <ControlStyle />
                                                                                        <asp:TemplateField HeaderText="Path" SortExpression="Path">
                                                                                                <asp:TextBox ID="Path1"  ValidationGroup="ValGrpEdit" runat="server" CssClass="text" Height="76px" Text='<%# Bind("Path") %>'
                                                                                                <asp:CustomValidator ID="txtApplicationPathV" ValidationGroup="ValGrpEdit" runat="server"
                                                                                                    ErrorMessage="Please fill in a path either in URL / Path or URL / Path" ClientValidationFunction="ValidateEdit"
                                                                                                    ControlToValidate="Path1" ValidateEmptyText="true">*</asp:CustomValidator>
                                                                                                <asp:Label ID="Path2" runat="server" CssClass="DisplayDesc" Text='<%# Bind("Path") %>'
                                                                                            <ItemStyle ForeColor="Black" />
                                                                                            <ControlStyle />

i tryied every possibilities,but am unable to validate the fields,also not able to show message box.please help..
Posted 20-Aug-12 12:14pm
Edited 20-Aug-12 14:38pm
Sergey Alexandrovich Kryukov at 20-Aug-12 18:20pm
From reading just the title: showing a MessageBox cannot validate anything at all. Validation is something completely different.
Even though your request may make a full sense, such an inaccurate title (especially in the case where it is not even a question), will scare off many from even reading the rest of your too long post. Including myself.

software_Engi08 at 20-Aug-12 18:32pm
i have updated my tittle.
Christian Graus at 20-Aug-12 18:34pm
This is a code dump. No-one is going to read it all. I have a headache justfrom scrolling down this far.
software_Engi08 at 20-Aug-12 18:44pm
made my post short
Kenneth Haugland at 20-Aug-12 20:06pm
Show a simple code that illustrates the problem, and remove all other code. We dont need to understand how it fits into your code, just your problem.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try using vb codes man, vb codes is more easier to apply than script
software_Engi08 at 21-Aug-12 5:59am
can i get any sample code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 314
1 Suvendu Shekhar Giri 240
2 stibee 213
3 Mika Wendelius 208
4 Richard Deeming 190
0 OriginalGriff 9,061
1 Sergey Alexandrovich Kryukov 8,773
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,494
4 F-ES Sitecore 2,438

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 21 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100