Creating a ValidatedField

In this final section, we create a ValidatedField custom field, which automatically validates the data that a user enters into GridView when editing a record. ValidatedField uses RequiredFieldValidator to check whether a user has entered a value, and CompareValidator to check whether the value is the correct data type (see Figure 11.25).

Figure 11.25. Using ValidatedField to edit a record.

image

ValidatedField is a composite field. The field contains three child controls—a TextBox, RequiredFieldValidator, and CompareValidator—wrapped up in a container control.

The code for the ValidatedField is too long to include in this ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.