If you want to insert new records, your only choices are DetailsView and FormView.
If you want to update or delete data (but not necessarily insert new records), choose GridView, DetailsView, or FormView. Although DataList is capable of providing UI for editing, it does not take advantage of the data source’s ability to do this automatically like GridView, and you’ll need to write custom code to make it work. Refer to an ASP.NET v1 reference for more information (the topic is outside the scope of this book).
If you only want to display read-only values, you can use any of the templated controls .
Choosing a control based on formatting and layout of the data records:
If you want to display multiple data records at the same time, choose between GridView, DataList, and Repeater:
GridView: Displays each data record as a row in a table. Fields of the data record are displayed in the table cells (one field per cell, or using a template, as many fields per cells as you need). The contents of each cell are defined by the TemplateField.ItemTemplate property.
DataList: Displays each data record as a cell in a table. The number of data records per row in the table is determined by the DataList’s RepeatColumns property. The ItemTemplate property allows you to define the template rendering of each data record within the table cell.
Repeater: Displays each data record as a user-defined item, defined by the Repeater’s ItemTemplate property. There is no built-in table for layout, so the items simply flow from one to the next (within a tag, so styles are applied).
If you want to display one record at a time, choose between DetailsView and FormView:
DetailsView: Displays each data record as a table of two columns, where each row typically contains a single field (the left cell is the header and the right cell the value). Using TemplateField, you can define the contents of each value cell using the TemplateField.ItemTemplate property.
FormView: Displays each data record as a single cell in a table with one row. The contents of the table cell are defined by the FormView’s ItemTemplate property.
=================================
GridView
DataList
Repeater
DetailsView
Form View
From version 1.x?
No
Yes
Yes
No
No
Number of records shown at once
Multiple
Multiple
Multiple
Single
Single
Can update records?
Yes
No[*]
No
Yes
Yes
Can delete records?
Yes
No[*]
No
Yes
Yes
Can insert records?
No
No
No
Yes
Yes
Can select records?
Yes
No[*]
No
Yes[**]
Yes[**]
Supports paging?
Yes
No
No
Yes
Yes
Renders data record as...
Row in multicolumn table
Cell in multirow/column table
Item in a (no table)
Single table of two columns
Single cell in a one-row table
Templates are optional?
Yes
No
No
Yes
No
Supports header/footer
Yes
Yes
Yes
Yes
Yes
No comments:
Post a Comment