Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hii Experts I have a grifview in which 3 textbox are there in the edit item template.I want to validate these textboxes with required field validation .I have done using very old fashion validation(given below).Please suggest me some new technique for validation inside gridview edit item template.If possible suggest me in javascript.Here is my source code
 
<asp:GridView ID="GvEditEvent" runat="server" Width="500px" AutoGenerateColumns="False" DataKeyNames="EId" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
        <Columns>
            <asp:TemplateField HeaderText="Event Date">
            <EditItemTemplate>
                <asp:TextBox ID="txtEDate" Text='<%#Bind("EDate") %>' runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2"   runat="server" ControlToValidate="txtEDate" ErrorMessage="Please enter EventDate">*</asp:RequiredFieldValidator>
                  <ajaxToolkit:CalendarExtender ID="CalendarExtender2"
                                                      runat="server"
                                                      TargetControlID="txtEDate"
                                                      CssClass="MyCalendar"
                                                      Format="dd/MM/yyyy"
                                                      Enabled="True">
                       </ajaxToolkit:CalendarExtender>
 
            </EditItemTemplate>
              <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("EDate") %>'></asp:Label>
               </ItemTemplate>
               <ItemStyle Width="90px" HorizontalAlign="center" VerticalAlign="top" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Event Details">
              <EditItemTemplate>
                <asp:TextBox ID="txtEDetails" Text='<%#Bind("EDetails") %>' TextMode="multiline" Height="150px" runat="server"></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2"   runat="server" ControlToValidate="txtEDetails" ErrorMessage="Please enter EventDetails">*</asp:RequiredFieldValidator>
 
            </EditItemTemplate>
               <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("EDetails") %>'></asp:Label>
                </ItemTemplate>
                 <ItemStyle Width="130px" HorizontalAlign="center" VerticalAlign="top" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="EventImage">
                <EditItemTemplate>
                    <asp:FileUpload ID="fupEImage" runat="server" />
                </EditItemTemplate>
             <ItemTemplate>
                    <asp:Image ID="Image1" ImageUrl='<%#Eval("Img")%>'  Width="100px" Height="100px" runat="server" />
                        <asp:HiddenField ID="hdnImage" Value='<%#Eval("Img")%>' runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
Is there any other way of giving validation .Because I m not able to show validation summery in the gridview
Thank You
Sandeep Mishra
Software Developer
Posted 3-Feb-11 19:19pm
Edited 3-Feb-11 19:28pm
v2
Comments
Sunasara Imdadhusen at 4-Feb-11 0:22am
   
What's your problem?
Dwayne J. Baldwin at 8-Feb-11 3:42am
   
Have you tried without using ID="RequiredFieldValidator2"? It should work fine without very old javascript. :)

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



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 4 Feb 2011
Copyright © CodeProject, 1999-2014
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