Datagrid vs. Datalist vs. Repeater
Posted by tcle on July 20, 2007
Datagrid
An big advantage of the datagrid is that it is very simple to use and easily customizable with some cool color settings for borders,backgrounds etc. It also supports paging and sorting which also is accompanied by some customizable features for example, the way the page index can be displayed, as numbers or “previous and next” links etc.
- However, the DataGrid’s built-in paging capabilities are horrible in terms of performance. It’s built-in paging grabs all the rows from the database with each call and then only displays the necessary records. For any real-world application, you will need to turn off the built-in paging and create your own custom paging. ( refer to letting AllowCustomPaging property to “true” and manually implement the function in your own code).
- In term of displaying information, Datagrid is not flexible as Repeater (CSS).
- The ASP.NET DataGrid requires the ViewState for its sorting capabilities. So, unless you want all the viewstate data to decrease the performance of your application, you will have to turn off its built-in sorting and create your own sorting methodology.
DataList
Like DataGrid, it render content within HTML tag like <table> or <span> but it dose not use specified columns (DataGridColumn base class) to display items but use template like Repeater. The outcome is that you can mix up HTML content and databinding syntax.
DataList dose not support paging and sorting unless you give some effort on implementing these functions. Again hing level of customization with rendered HTML mark up is the reason why one might prefer DataList over DataGrid.
Repeater
A Repeater is designed to let the user customize its output and thus have complete control over what is being rendered.
An important thing to remember about the Repeater is that, it is not derived from the WebControl class, like the DataGrid and DataList due to which it lacks the stylistic properties common to both the DataGrid and DataList. So if you want to make things look pretty in a repeater, write it yoursel.
Among all the 3 web controls in question, Repeater offers the best performance, though only slightly ahead of the datalist but beating datagrid by a considerable margin.
Source: