The first Asp.net entry post starts with the data control!
Five data controls in ASP. NET 2.0: gridview, datalist, repeater, detailsview, and formview.
Summary:
1. The first three are used to present multiple records, and the last two are used to present single data details, that is, common record details.
2. The layout of the gridview and detailsview controls is fixed, and the layout function of custom data display is limited, which is generally suitable for simple data presentation. 3. datalist, repeater, and formview data controls have strong custom Layout capabilities. If data presentation requires a complicated layout scheme, these three controls are preferred.
4. The gridview, detailsview, and formview controls are newly added to. NET 2.0, with built-in paging, sorting, and other functions. Their improvements are incomparable to the controls provided by 1.1.
5. datalist and repeater are controls provided in version 1.1. The built-in functions are weak. You need to implement paging, sorting, data events, and other functions on your own.
Interestingly, on the current Asp.net platform, if the detailsview corresponds to the formview when a single column of data is displayed, the detailsview layout is fixed and the formview custom layout is fixed, when presenting multiple columns of data, only the gridview is responsible for the layout of fixed data. In terms of function, there is no corresponding control that matches the gridview.
The data function provided by datalist is too weak compared with that provided by the gridview. datalist requires programmers to write their own code to implement the desired functions, compared to the data presentation task of gridview, which can be carried out without programming.
Gridview control:
The gridview control displays data in the form of a table, and provides the function of sorting, paging, reading data, and editing or deleting a single record.
Note: The gridview control is a successor control of the DataGrid control provided in earlier versions of ASP. NET. In addition to adding new features that utilize the data source control function, the gridview control also implements some improvements, for example, define the functions of multiple primary key fields, use the bound fields and templates to improve user interface customization, and use the new model to process or cancel events.
Detailsview control:
The detailsview control displays a record in the form of a table at a time, and provides the ability to read multiple records and insert, update, and delete records. The detailsview control is usually used in the master/details solution. In this solution, the selected records in the master control (such as the gridview Control) determine the records displayed by the detailsview control.
Formview control:
The formview control is similar to the detailsview control. It presents one record in the data source at a time and provides the ability to read multiple records and insert, update, and delete records. However, the difference between the formview control and the detailsview control is that the detailsview control uses a table-based layout in which each field of the data record is displayed as a row in the control. The formview control does not specify the predefined layout for displaying records. In fact, you will create a template containing the control to display each field in the record. This template contains the format, controls, and binding expressions used to set the form layout.
Repeater control:
The Repeater control displays a read-only list using a set of records returned by the data source. Similar to the formview control, the repeater control does not specify a built-in layout. You can use a template to create a repeater control layout.
Datalist control:
The datalist control presents data in the form of a table. With this control, you can use different la s to display data records, such as arranging data records into columns or rows. You can configure the datalist control so that you can edit or delete records in the table. (The datalist control does not use the data modification function of the data source control. You must provide this code yourself .)