So many different controls to choose from! What are best practices for determining which control to use for displaying data in ASP.NET?
A GridView control is used when you want to display a set of data in a table format. A Repeater is when you want to display data repeatedly, but not necessarily in a tabular format. If you want a table, use a GridView, otherwise use a Repeater. The speed of loading/updating is negligible between the two.
Between the two, ListView gives you a lot more events and built-in commands for editing, selecting, inserting. Additionally paging and grouping functionality. A Repeater is extremely simple, it repeats a layout with the data. Since you're building the layout by hand, Listview and Repeater require more code.
DataList has more features but more limited in design when compared to Repeater. In the other hand, it has more flexibility and less features than GridView. Also, DataList has RepeatDirection, RepeatColumns and RepeatLayout properties, which are unique for DataList control.
Repeater is faster because it offers only basic data bound control rendering functionalities. If you want to show data and you don't need any complex features described below then repeater is the right joice.
It's really about what you trying to achieve
Gridview - Limited in design, works like an html table. More in built functionality like edit/update, page, sort. Lots of overhead.
DataGrid - Old version of the Gridview. A gridview is a super datagrid.
Datalist - more customisable version of the Gridview. Also has some overhead. More manual work as you have to design it yourself.
ListView - the new Datalist :). Almost a hybrid of the datalist and gridview where you can use paging and build in Gridview like functionality, but have the freedom of design. One of the new controls in this family
Repeater - Very light weight. No built in functionality like Headers, Footers. Has the least overhead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With