RequiredFieldValidator only works for one validation - asp.net

I have a web application written in VS2010.
I have a GridView in which I want to add 2 different validations to a field in edit mode. One validation is that it is a required field. The other validation is a max. length of 80 characters.
Below is my HTML:
<asp:GridView ID="UserInfoGridView" runat="server" AutoGenerateColumns="False"
Caption="User Information" CaptionAlign="Top" CssClass="grid" HorizontalAlign="Left"
PageSize="1" Width="400px" ShowHeaderWhenEmpty="true" Height="60px"
OnRowCancelingEdit="UserInfoGridView_RowCancelingEdit"
OnRowEditing="UserInfoGridView_RowEditing"
OnRowUpdating="UserInfoGridView_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="Name" ItemStyle-Wrap="false">
<EditItemTemplate>
<asp:TextBox ID="uigvTxtBoxName" runat="server" Text='<%# Bind("UserName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEditName" ControlToValidate="uigvTxtBoxName" runat="server"
ErrorMessage="Required field." ValidationGroup="EditUserNameValidation" Display="Dynamic"
CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="MaxValEditName" ControlToValidate="uigvTxtBoxName" runat="server"
ErrorMessage="Maximum length is 80." ValidationGroup="EditUserNameValidation" Display="Dynamic"
CssClass="message-error" ValidationExpression="^.{1,80}$">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="uigvLblName" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email Address" ItemStyle-Wrap="false">
<EditItemTemplate>
<asp:TextBox ID="uigvTxtBoxEmail" runat="server" Text='<%# Bind("UserEmail") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEditEmail" ControlToValidate="uigvTxtBoxEmail" runat="server"
ErrorMessage="Required field." ValidationGroup="EditUserEmailValidation" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="MaxValEditEmail" ControlToValidate="uigvTxtBoxEmail" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="EditUserEmailValidation" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="uigvLblEmail" runat="server" Text='<%# Bind("UserEmail") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ShowHeader="False" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<EditItemTemplate>
<asp:Button ID="uigvUpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="uigvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="uigvEditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton">
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle Wrap="True" />
</asp:GridView>
When in edit mode if the field is left blank, both of the error messages are displayed. If the user enters more than 80 characters, neither message is displayed.
I did this in an application using VS 2012. Can this be done in VS2010? If so, where am I going wrong?
Thanks.

use regularexpression validator or range validator instead of requiredfield validator for validating max length.
So you need to use one required field and the other is regular expression validator.

Related

asp.net Gridview checkbox is clickable without edit

I have a checkbox on my griview and its able to be clicked before the edit button is clicked, this doesn't make sense to me and its not something I have came across before. In theory the checkbox should be greyed out until a user clicks the edit button.
Nothing can be updated but it just doesn't make any sense as to why this functionality would be available. I have set up Gridviews before using checkboxes and never came across this. Below is my code:
<asp:GridView ID="gvLeagues" runat="server"
AutoGenerateColumns="False"
onpageindexchanging="gvLeagues_PageIndexChanging"
onrowcancelingedit="gvLeagues_RowCancelingEdit"
onrowdatabound="gvLeagues_RowDataBound"
onrowediting="gvLeagues_RowEditing"
onrowupdating="gvLeagues_RowUpdating"
onsorting="gvLeagues_Sorting" EnableModelValidation="True"
CssClass="footable"
EditRowStyle-CssClass="table table-bordered" >
No Data Found.
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("Name")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Created Date" SortExpression="CreatedDate">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="true" Text='<%# Bind("CreatedDate")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("CreatedDate")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Day" SortExpression="Day">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Day")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label3" runat="server" Text='<%# Bind("Day")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Season" SortExpression="Season">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Season")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("Season")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Enabled" SortExpression="Enabled">
<EditItemTemplate>
<asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' />
</EditItemTemplate>
<ItemTemplate><asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' /></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When using the ItemTemplate, you are the one specifying what and how you want to see it. Just set that checkbox as disabled.
<asp:TemplateField HeaderText="Enabled" SortExpression="Enabled">
<EditItemTemplate>
<asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' />
</EditItemTemplate>
<ItemTemplate><asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' enabled="False"/></ItemTemplate>
</asp:TemplateField>

gridview Validation is triggered in emptydatatemplate when entry is valid

I have a Gridview that has 3 columns, ID, Text, Action. I am using VS2010. When the grid is empty and the user enters text in the text field, I would like the field to be validated as a required field and a max. length. These validations work fine if there is data in the grid but when the grid is empty, the required validation is triggered after the user enters data. If the user enters a second time, the data is successfully added to the database and refreshed in the grid.
Secondly, the column headers will not show when the grid is empty even though I had the attribute: ShowHeaderWhenEmpty="true"
This is my markup:
<asp:GridView ID="SubjectInfoGridView" runat="server"
AutoGenerateColumns="false" Caption="Personal Subject List"
CaptionAlign="Top" CssClass="grid"
RowStyle-Wrap="true" HorizontalAlign="Left" ShowFooter="true"
AllowPaging="false" PageSize="5" ShowHeaderWhenEmpty="true"
onrowcancelingedit="SubjectInfoGridView_RowCancelingEdit"
onrowediting="SubjectInfoGridView_RowEditing"
onrowdeleting="SubjectInfoGridView_RowDeleting"
onrowcommand="SubjectInfoGridView_RowCommand"
onrowupdating="SubjectInfoGridView_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="Subject ID">
<ItemTemplate>
<asp:Label ID="sigvLblSubjectID" runat="server" Text='<%# Bind("SubjectID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subject" ItemStyle-Wrap="false">
<ItemTemplate>
<asp:Label ID="sigvLblSubject" runat="server" Text='<%# Bind("Subject") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="sigvTxtBoxEditSubject" runat="server" Text='<%# Bind("Subject") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEditSubject" ControlToValidate="sigvTxtBoxEditSubject" runat="server"
ErrorMessage="Required field." ValidationGroup="EditSubjectValidation" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="MaxValEditSubject" ControlToValidate="sigvTxtBoxEditSubject" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="EditSubjectValidation" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="sigvTxtBoxInsertSubject" runat="server" Text='<%# Bind("Subject") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldInsertSubject" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Required field." ValidationGroup="InsertSubjectValidation" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="MaxValInsertSubject" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="InsertSubjectValidation" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="sigvEditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton">
</asp:Button>
<asp:Button ID="sigvDeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete" CssClass="gridActionbutton" OnClientClick="return confirm('Are you sure you want to delete this Device Information?')" >
</asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="sigvUpdateButton" runat="server" CausesValidation="True" ValidationGroup="EditSubjectValidation" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="sigvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="sigvAddButton" runat="server" CommandName="Add" Text="Add Subject" Width="90%" CausesValidation="true"
CssClass="gridActionbutton" ValidationGroup="InsertSubjectValidation">
</asp:Button>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<tr>
<td colspan="3" style="text-align:center;">
No User-defined Subjects were found for you. Subjects can be added by clicking the 'Add Subject' Button.
</td>
</tr>
<tr>
<td></td>
<td>
<asp:TextBox ID="sigvTxtBoxInsertSubject" runat="server" Text='<%# Bind("Subject") %>' Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldInsertSubjectEmpty" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Required field." ValidationGroup="InsertSubjectValidation" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="MaxValInsertSubjectEmpty" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="InsertSubjectValidation" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RegularExpressionValidator>
</td>
<td>
<asp:Button ID="sigvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Subject" Width="90%" CausesValidation="true"
CssClass="gridActionbutton" ValidationGroup="InsertSubjectValidation">
</asp:Button>
</td>
</tr>
</EmptyDataTemplate>
</asp:GridView>
So, why won't the headers show when the grid is empty and what am I doing wrong with the validation that triggers the RequiredValidation after data is entered in the field?
Thanks!
UPDATE
I solved the 'Header problem' but just adding them to the EmptyDataTemplate. But the validation is still a problem.
I did this using VS2012 at another company and it was not a problem. I tried making the TextBox id different than the Insert ID and it still gives the same error.
I figured it out...
In case anybody else has this problem.
To correct the validation, I removed the text binding (Text='<%# Bind("Subject") %>'). Then I changed the ID for the Subject field to the same as in the Footer when I add a row when there is data. This allows me to only check one control within the RowBound event.
This is the data row in the EmptyDataTemplate:
<tr>
<td></td>
<td>
<asp:TextBox ID="sigvTxtBoxInsertSubject" runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldInsertSubjectEmpty" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Required field." ValidationGroup="InsertSubjectValidationEmpty" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="MaxValInsertSubjectEmpty" ControlToValidate="sigvTxtBoxInsertSubject" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="InsertSubjectValidationEmpty" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RegularExpressionValidator>
</td>
<td>
<asp:Button ID="sigvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Subject" Width="90%" CausesValidation="true"
CssClass="gridActionbutton" ValidationGroup="InsertSubjectValidationEmpty" >
</asp:Button>
</td>
</tr>

Telerik Radgrid required field issue

I have a radgrid displayed on a page and am wanting to make a particular field required when in insert and edit mode but don't necessarily know how to go about this.
Using regular validators
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="*" ControlToValidate="TextBox1">
</asp:RequiredFieldValidator>
Like this:
<telerik:RadGrid ID="RadGrid1" runat="server">
<MasterTableView AutoGenerateColumns="False">
<Columns>
<telerik:GridTemplateColumn HeaderText="ContactName" UniqueName="TemplateColumn">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ContactName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ContactName") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
http://www.telerik.com/help/aspnet-ajax/grid-validation.html
For common validation like required field, I found RadGrid has it built-in support
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/validation
<telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" UniqueName="ShipName">
<ColumnValidationSettings EnableRequiredFieldValidation="true" EnableModelErrorMessageValidation="true">
<RequiredFieldValidator ForeColor="Red" ErrorMessage="This field is required"></RequiredFieldValidator>
<ModelErrorMessage BackColor="Red" />
</ColumnValidationSettings>
where ModelErrorMessage control validation is available only in .NET 4.5 when ModelBinding is used.

RegularExpressionValidator for textbox inside GridView not working

I have GridView:
<asp:GridView ID="MyGridView" runat="server" ShowFooter="true"
AutoGenerateColumns="False" Visible="True">
<Columns>
<asp:BoundField DataField="id" ItemStyle-HorizontalAlign="center"/>
<asp:BoundField DataField="fullName" />
<asp:TemplateField HeaderText="situation>">
<ItemTemplate>
<asp:DropDownList ID="dl_situation" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tbNr" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
It work fine, but when I add RegularrExpressionValidator for textbox with id="tbDate" mygrid does not work
This regular expression must accept datetime in format "dd.MM.yyyy"
<asp:GridView ID="MyGridView" runat="server" ShowFooter="true"
AutoGenerateColumns="False" Visible="True">
<Columns>
<asp:BoundField DataField="id" ItemStyle-HorizontalAlign="center"/>
<asp:BoundField DataField="fullName" />
<asp:TemplateField HeaderText="situation>">
<ItemTemplate>
<asp:DropDownList ID="dl_situation" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tbNr" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularCert" runat="server"
ControlToValidate="tbDate" ErrorMessage="Incorect Data"
ValidationExpression=
"(0[1-9]|[12][0-9]|3[01])[-.](0[1-9]|1[012])[-.](19|20)[0-9]{2}"
Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="tbDate">
</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I think you typed "tbData" instead of "tbDate" in the ControlToValidate property
<asp:RegularExpressionValidator ID="RegularCert" runat="server"
ControlToValidate="tbDate" ErrorMessage="Incorect Data" ValidationExpression= "(0[1-9]|[12][0-9]|3[01])[-.](0[1-9]|1[012])[-.](19|20)[0-9]{2}"
Display="Dynamic"></asp:RegularExpressionValidator>
I changed ClientIDMode to Predictable for TextBox, RegularExpressionValidator and RequiredFieldValidator and began to work
change ControlToValidate="tbData" to ControlToValidate="tbDate" for <asp:RegularExpressionValidator
Have you tried placing the <asp:RegularExpressionValidator ...> inside the
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
</ItemTemplate>
also you need to indicate some text to display if it fails the regex validation
actually what Hallie said is more than likely the answer ha

validation of edit row and insert row in GridView

Simple question? I have a gridview with an insert row in the footer and i have validation controls for that row and the edittemplate how do get it to only validate for that row because when i do an edit it validates the insert row aswell. I just wnat to validate the insert row or edit row.
<asp:GridView ID="PageSettings" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
DataKeyNames="Id"
DataSourceID="ObjectDataSourcePages"
OnLoad="PageSettings_Load"
OnRowDataBound="PageSettings_DataBound"
OnRowCommand="PageSettings_RowCommand"
OnRowCreated="PageSettings_RowCreated"
OnRowEditing="PageSettings_RowEditing"
OnRowCancelingEdit="PageSettings_RowCancelingEdit"
OnRowUpdating="PageSettings_RowUpdating"
OnPageIndexChanging="PageSettings_PageIndexChanging"
OnSorting="PageSettings_Sorting"
OnSorted="PageSetting_Sorted"
PageSize="2"
ShowFooter="True"
ShowHeaderWhenEmpty="True">
<Columns>
<asp:TemplateField HeaderText="Page Name" HeaderStyle-HorizontalAlign="Left" SortExpression="Name">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireName" runat="server"
ControlToValidate="Name"
CssClass="gridview-error"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireInsertName" runat="server"
ControlToValidate="InsertName"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Path" HeaderStyle-HorizontalAlign="Left" SortExpression="Path">
<ItemTemplate>
<%# Eval("Path") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Path" runat="server" Text='<%# Bind("Path") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequirePath" runat="server"
ControlToValidate="Path"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertPath" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireInsertPath" runat="server"
ControlToValidate="InsertPath"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Route Value" HeaderStyle-HorizontalAlign="Left" SortExpression="RouteValue">
<ItemTemplate>
<%# Eval("RouteValue") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="RouteValue" runat="server" Text='<%# Bind("RouteValue") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertRouteValue" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RegExp" HeaderStyle-HorizontalAlign="Left" SortExpression="RegExp">
<ItemTemplate>
<%# Eval("RegExp") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="RegExp" runat="server" Text='<%# Bind("RegExp") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertRegExp" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
You can use a
Validation Group
Define a separate group for each operation
SaveRecords
&
EditRecords
. You have to specify each validation group on the Save/Edit buttons & all corresponding validation controls to fire them for that event.
MSDN
After a long Time
but you must add in footer requiredfieldvalidator a validationgroup with a unique name and add this validationgroup to add button

Resources