Here is the list of the data-bound controls in ASP.NET:
- GridView
- DataList
- DetailsView
- FormView
- ListView
- Repeater
DataList is another data-bound control for displaying data as a table. It's a template-driven control and provides different templates to display data in normal, alternate, edit or select mode. You can also have templates for header and footer.
You can edit or delete rows in DataList, but the big disadvantage that makes me avoid using DataList is that it does not utilize the capabilities of data source controls for editing or deleting data. If you opt to use this control, you should consider that you have to write codes to handle data modification. I think generally the capabilities offered by the other data-bound controls saves you from using such a cumbersome control. I even wonder why they bothered to create it and add it to the list of data-bound controls!
DetailsView is a control usually used along with GridView control in master/detail scenarios. In this case, the selected row in the GridView control will be displayed in the DetailsView control.
DetailsView shows a single row at a time and provides paging, inserting new records, updating and deleting rows. It uses a table-based layout.
FormView is very similar to DetailsView, except that it's a template-driven control and doesn't provide a pre-defined layout. It contains several templates that allows developers to design the layout used for displaying the data.
ListView is a template-driven data-bound control. Like other template-driven controls, it uses several templates you can use to customize the layout of the data that is to be displayed. Unlike DataList control, it utilizes capabilities of the data source controls for common operations such as editing, inserting and deleting and also functionalities like sorting and paging.
Because it's the only control that implements IPageableItemContainer interface, it's the only one that can use DataPager control.
Repeater is used to create a read-only list of data rows. It's a template-driven control and allows you to customize the design of the displayed records by using templates. It has no default layout.
To wrap it up, whenever you reach the point where you have to choose the best control that suits your need best, you should consider what you exactly need the control to do, what kind of functionalities you want it to offer and whether you want to give it a customized look at design time or not.
No comments:
Post a Comment