Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ASP.NET Data-Bound Web Server Controls Overview 

Data-bound Web server controls are controls that can be bound to a data source control to make it easy to display and modify data in your Web application. Data-bound Web server controls are composite controls that combine other ASP.NET Web controls, such as Label and TextBox controls, into a single layout.

For example, a data-bound control such as a DetailsView control can bind to a set of results such as a table of employees containing each employee's name, address, job title, and so on. Within the DetailsView control, you can bind Label controls to a single data values such as the name or address field to create the data layout in the page.

In addition to enabling you to bind the control to a set of data results, data-bound controls enable you to customize the layout of the control using templates. They also provide a convenient model for handling and canceling events.

This topic discusses how data Web server controls bind to data as well as the data-bound controls that are included with ASP.NET.

Binding a Data-bound Web Server Control to Data

You can work with a data-bound control by binding it to a data source control such as an ObjectDataSource or SqlDataSource control. The data source control connects to a data source such as a database or middle-tier object and then retrieves or updates data. The data-bound control can then use this data. To perform the binding, you set the data-bound control's DataSourceID property to point to a data source control. When a data-bound control is bound to a data source control, little or no additional code is required for data operations, because the data-bound control can automatically take advantage of the data services provided by the data source control.

NoteNote

In previous versions of ASP.NET, data-bound controls were bound to data using the DataSource property and required you to write code to handle operations such as displaying, paging, sorting, editing, and deleting data. Although you can still bind controls to data using the DataSource property (and use existing code), you can now performing binding using the DataSourceID property instead.

For more information about data source controls, see Data Source Web Server Controls.

GridView Control

The GridView control displays data as a table and provides the capability to sort columns, page through data, and edit or delete a single record.

NoteNote

The GridView control is the successor to the DataGrid control available in earlier versions of ASP.NET. Along with the added ability to take advantage of the capabilities of data source controls, the GridView control offers improvements such as the ability to define multiple primary key fields, improved user interface customization using bound fields and templates, and a new model for handling or canceling events.

For more information, see GridView Web Server Control and Comparing the GridView and DataGrid Web Server Controls.

DetailsView Control

The DetailsView control renders a single record at a time as a table and provides the capability to page through multiple records, as well as to insert, update, and delete records. The DetailsView control is often used in master-detail scenarios where the selected record in a master control such as a GridView control determines the record displayed by the DetailsView control.

For more information, see DetailsView Web Server Control.

FormView Control

The FormView control renders a single record at a time from a data source and provides the capability to page through multiple records, as well as to insert, update, and delete records, similar to the DetailsView control. However, the difference between the FormView and the DetailsView controls is that the DetailsView control uses a table-based layout where each field of the data record is displayed as a row in the control. In contrast, the FormView control does not specify a pre-defined layout for displaying a record. Instead, you create templates that contain controls to display individual fields from the record. The template contains the formatting, controls, and binding expressions used to lay out the form.

For more information, see FormView Web Server Control.

Repeater Control

The Repeater control renders a read-only list from a set of records returned from a data source. Like the FormView control, the Repeater control does not specify a built-in layout. Instead you create the layout for the Repeater control using templates.

For more information, see Repeater Web Server Control.

DataList Control

The DataList control renders data as table and enables you to display data records in different layouts, such as ordering them in columns or rows. You can configure the DataList control to enable users to edit or delete a record in the table. (The DataList control does not take advantage of the capabilities of data source controls for modifying data; you must supply this code yourself.) The DataList control differs from the Repeater control in that the DataList control explicitly places items in an HTML table, where as the Repeater control does not.

For more information, see DataList Web Server Control.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft