Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Updated 20-Aug-12 14: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

try using vb codes man, vb codes is more easier to apply than script
 
Share this answer
 
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)



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