The tabular DataBound controls are the main set of controls that you use when working with database data. These controls enable you to display and, in some cases, modify data retrieved from a database or other type of data source.
There are six tabular DataBound controls. These controls can be divided into two types: those that display multiple data items at a time and those that display a single data item at a time.
Following controls to display a set of data items:
There are six tabular DataBound controls. These controls can be divided into two types: those that display multiple data items at a time and those that display a single data item at a time.
Following controls to display a set of data items:
- GridView : Displays a set of data items in an HTML table. For example, you can use the GridView control to display all the records contained in the Movies database table. This control enables you to display, sort, page, select, and edit data.
- DataList : Displays a set of data items in an HTML table. Unlike the GridView control, more than one data item can be displayed in a single row.
- Repeater : Displays a set of data items using a template. Unlike the GridView and DataList controls, a Repeater control does not automatically render an HTML table.
- ListView : Displays a set of data items using a template. Unlike the Repeater control, the ListView control supports sorting, paging, and editing database data.
- DetailsView : Displays a single data item in an HTML table. For example, you can use the DetailsView control to display a single record from the Movies database table. This control enables you to display, page, edit, and add data.
- FormView : Uses a template to display a single data item. Unlike the DetailsView, a FormView enables you to layout a form by using templates.
Most data-bound controls supplied with ASP.NET automatically enclose the displayed data with additional markup. As an example, the GridView control displays its data rendered inside of an HTML table (<table>), displaying each record of data bound to it as a table row (<tr>) and each record field as a cell within the row (<td>). While you can use TemplateField elements and other tools to customize the appearance of a GridView, the GridView's output will still be enclosed within a table element. But sometimes you want to have complete control over the appearance of the HTML markup generated by the data-bound controls. This is exactly where the ListView control comes into play. The ListView control does not automatically enclose its rendered output in any additional markup. Instead, it's your responsibility to specify the precise HTML rendered for the ListView control. You specify the precise markup using the ListView's built-in templates. Table 1 lists the templates supported by the ListView control.
ListView Template & Purpose
ListView Template & Purpose
- AlternatingItemTemplate : Display alternating items with different markup to help viewers distinguish consecutive items.
- EditItemTemplate : Controls display when an item is in edit mode.
- EmptyDataTemplate : Controls display when the ListView's data source returns no data.
- EmptyItemTemplate : Controls the display for an empty item.
- GroupSeparatorTemplate : Controls the content to display between groups of items.
- GroupTemplate : Specifies a container object such as a table row, div, or span element for the content.
- InsertItemTemplate : Specifies content to render when users insert an item.
- ItemSeparatorTemplate : Controls the content to display between individual items.
- ItemTemplate : Controls content to display for individual items.
- LayoutTemplate : Specifies the root element that defines a container object, such as a table, div, or span element that surrounds content defined in the ItemTemplate or GroupTemplate.
- SelectedItemTemplate : Specifies the content to display for the currently selected item.