The gridview is intelligent and provides a lot of representations directly. It is one of the most complex and resource-consuming parts of the three. It is often used for list data processing, but it is better not to have too much data;
Repeater: Actually, it is to implement the repeated display function, which has a high degree of customization. It is similar to writing a circular statement in ASP to automatically generate a data list, is linear processing, very fast. direct output. This can be used when the data volume is large.
Datalist: As mentioned above, it is between the two;
5 Data source controls in. Net 2, GridView, DataList, Repeator, DetailsView, FormView
The first three are used to present multiple columns of data, and the last two are used to present a single column of data, that is, common data details.
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.
DataList, Repeator, and FormView data controls have strong custom Layout capabilities. If data presentation requires a complicated layout scheme, these three controls are
Preferred
GridView, DetailsView, and FormView are both new controls in version 2.0, with built-in paging, sorting, and other functions. Their improvements are incomparable to the controls provided in version 1.1.
DataList and Repeator 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 Aspnet platform, if the DetailsView corresponds to the FormView when a single column of data is displayed, the DetailsView layout is fixed.
FormView custom Layout: when multiple columns of data are displayed, only the GridView is responsible for the layout of fixed data. In terms of function, no corresponding control matches the GridView.
The data function provided by DataList is too weak compared with that provided by the GridView. Compared with that provided by the GridView, DataList can be used to present data without programming.
Programmers are required to write their own code to implement the desired functions. The assumption is to be 1.1 compatible, so DataList is not upgraded. In order to catch up with the progress, it is not like upgrading
When the DataGrid is the same as the GridView, The DataList is upgraded to ListView... we hope that later. Net Framework 3 will be improved.
This. DataList1.DataKeyField = "id" of datalist; equivalent to this. GridView1.DataKeyNames = new string [] {"id"} of the Gridview "};
Int id = Convert. ToInt32 (this. GridView1.DataKeys [e. RowIndex]. Value );
Int id = Convert. ToInt32 (this. DataList1.DataKeys [e. Item. ItemIndex]. ToStirng ());
Datalist Control
OnDeleteCommand
OnEditCommand
OnUpdateCommand
OnCancelCommand
If the corresponding commandname is delete, update, edit, and cancel