The last step is to add validation to editing the record.
For this example I'll show you how to validate that the last name is filled in
and that the email address is in valid form. Stop the project from running to
return to design mode in Visual Studio 2010.
Click the smart tag next to the GridView control again. You're still in
Edit Template mode and you need to exit this mode. To exit this mode simply
click on the End Template Editing link on the pop-up menu.
You should see the GridView control again with the bound fields. Click
the smart tag and click Edit Columns… from the pop-up menu.
Click the LastName field in the Selected Fields list and then click the
Convert this field into a Template Field link.
Do the same for the EmailAddress field. Now click the OK button.
Click the smart tag next to the GridView control again and select Edit
Templates from the pop-up menu.
Select the LastName EditItemTemplate from the list.
Drag a RequiredFieldValidator control next to the textbox.
Set the ControlToValidate property of the RequiredFieldValidator to
Set the ForeColor property to Red.
the ErrorMessage property to Please enter a last name.
the smart tag next to the GridView control again. Select the EmailAddress
EditItemTemplate value from the list.
a RegularExpressionValidator next to the textbox.
the ControlToValidate property to Textbox2.
the ForeColor property to Red.
the ErrorMessage property to Please enter a valid email address.
in the ValidationExpression property to display a the button with the ellipse.
Click this button. This displays the list of standard expressions. Select
Internet e-mail address and click the OK button.
Now run the project again. Click the edit link and blank
out a name. If you click the update button the validation message should
appear. If you take off the ".com" from the email address you should
also see the email error message when you click Update.