Click here to Skip to main content
12,767,637 members (52,156 online)
Rate this:
 
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"
                                                                                  CssClass="GridStyle"
                                                                                    Font-Names="Tahoma" Font-Size="11px"
                                                                                    HeaderStyle-CssClass="HeaderStyle" HorizontalAlign="Left"
                                                                                  
                                                                                     Width="100%">
                                                                                    <%--<RowStyle BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" ForeColor="Blue"
                                                            Wrap="True" />--%>
                                                                                    <Columns>
                                                                                     
                                                                                             <asp:CommandField 
                       ShowEditButton="True" CausesValidation="true" ValidationGroup="ValGrpEdit"></asp:CommandField>
                                                                                             
                                                                                      
                                                                                        <asp:TemplateField ShowHeader="False">
                                                                                            <ItemTemplate>
                                                                                                <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" 
                                                                                                    CommandName="Delete" Text="Delete"></asp:LinkButton>
                                                                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                
                                                                                        <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                                                                            <EditItemTemplate>
                                                                                                <asp:TextBox ID="Name1" runat="server" CssClass="text" Text='<%# Bind("Name") %>'
                                                                                                    ValidationGroup="ValGrpEdit"></asp:TextBox>
                                                                                                <asp:RequiredFieldValidator ID="RequiredName" runat="server" ControlToValidate="Name1"
                                                                                                    ErrorMessage="Please enter a valid Name."  EnableClientScript="true" ValidationGroup="ValGrpEdit" Width="16px">*</asp:RequiredFieldValidator>
                                                                                            </EditItemTemplate>
                                                                                            <ItemTemplate>
                                                                                                <asp:Label ID="Name2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                                                                            </ItemTemplate>
                                                                                            <ItemStyle ForeColor="Black" Width="15%" />
                                                                                            <ControlStyle />
                                                                                        </asp:TemplateField>
                                                                          
                                                                                  
                                                                            
                                                                                   
                                                                                        <asp:TemplateField HeaderText="Path" SortExpression="Path">
                                                                                            <EditItemTemplate>
                                                                                                <asp:TextBox ID="Path1"  ValidationGroup="ValGrpEdit" runat="server" CssClass="text" Height="76px" Text='<%# Bind("Path") %>'
                                                                                                    TextMode="MultiLine"></asp:TextBox>
                                                                                                <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>
                                                                                            </EditItemTemplate>
                                                                                            <ItemTemplate>
                                                                                                <asp:Label ID="Path2" runat="server" CssClass="DisplayDesc" Text='<%# Bind("Path") %>'
                                                                                                    Visible="false"></asp:Label>
                                                                                               
                                                                                            </ItemTemplate>
                                                                                            <ItemStyle ForeColor="Black" />
                                                                                            <ControlStyle />
                                                                                        </asp:TemplateField>
                                                                                      
                                                                          
                                                                           
                                                                            
                                                                                    </Columns>
                                                                                 
                                                                                </asp:GridView>

                                     


i tryied every possibilities,but am unable to validate the fields,also not able to show message box.please help..
Posted 20-Aug-12 13:14pm
Updated 20-Aug-12 15:38pm
v6
Comments
Sergey Alexandrovich Kryukov 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.

Sorry,
--SA
software_Engi08 20-Aug-12 18:32pm
   
i have updated my tittle.
Christian Graus 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 20-Aug-12 18:44pm
   
made my post short
Kenneth Haugland 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
 
good
Please Sign up or sign in to vote.

Solution 1

try using vb codes man, vb codes is more easier to apply than script
  Permalink  
Comments
software_Engi08 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 21 Aug 2012
Copyright © CodeProject, 1999-2017
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