Introducing the FormView Control
Thecontrol gives you the ability to work with a single record from a data source, similar to the control. The difference between the FormView and the DetailsView controls is that the DetailsView control uses a tabular layout where each field of the record is displayed as a row of its own. In contrast, the FormView control does not specify a pre-defined layout for displaying the record. Instead, you create a template containing controls to display individual fields from the record. The template contains the formatting, controls, and binding expressions used to create the form.
The FormView control is typically used for updating and inserting new records, and is often used in master/detail scenarios where the selected record of the master control determines the record to display in the FormView control.Â
The FormView control relies on the capabilities of the data source control to perform tasks such as updating, inserting, and deleting records. The FormView control renders only a single data record at a time, even if its data source exposes multiple records.
The FormView control can automatically page over the data in its associated data source one record at a time, provided that the data is represented by an object implementing theinterface, or that the underlying data source supports paging. The FormView control provides the user interface (UI) for navigating between records. To enable paging behavior, set the property to true and specify a value.
The FormView control exposes several events that you can handle to execute your own code. The events are raised before and after insert, update, and delete operations of the associated data source control. You can also write handlers for theand events.Â
The event model of the FormView control is similar to that of thecontrol. However, the FormView control does not support a selection event, because the current record is always the selected item.