Your shopping cart is empty!
The FormView control provides you with these options for binding to data:
Data binding using the DataSourceID property, which allows you to bind the FormView control to a data source control. This is the recommended approach because it allows the FormView control to take advantage of the capabilities of the data source control and to provide built-in functionality for updating and paging.
Data binding using the DataSource property, which allows you to bind to various objects, including ADO.NET datasets and data readers. This approach requires you to write the code for any additional functionality such as updating and paging.
When you bind to a data source using the DataSourceID property, the FormView control supports two-way data binding. In addition to the control displaying data, you can enable the control to automatically support insert, update, and delete operations on the bound data.
You build the user interface (UI) for the FormView control by creating templates. You specify different templates for different actions. You create an ItemTemplate template for display, insert, and edit modes. You can control paging using a PagerTemplate template, and you can customize the FormView control's header and footer using a HeaderTemplate and FooterTemplate, respectively. Using an EmptyDataTemplate, you can also specify a template to display when the data source does not return any data.
The item templates that you create for the FormView control specify the content of the control. As with the DetailsView control, you can also customize the display format of the FormView control by using style properties such as the EditRowStyle, EmptyDataRowStyle, FooterStyle, HeaderStyle, InsertRowStyle, PagerStyle, and RowStyle properties.
The following example shows a simple ASP.NET page that uses a FormView control to display data.
<%@ Page language="C#" %>
"-//W3C//DTD XHTML 1.0 Transitional//EN"