views:

127

answers:

3

When we get tabular data from the database and want to show on the UI, such as search result for products, products list or list of registered users for site administrators.

The famous control to do that is the grid view, while i prefer to use a simple repeater and this repeater loop on a table row, that's when i will need to bind this tabular data to a lot os client side scripts.

This is one of the reasons to use repeater over a grid.

And sometimes its better to use a grid view.

I just want you to share with me your ideas about when to use which and when not to use, i know there is no a standard for that, but i just wanted to hear ideas, and i will judge based on my current case.

A: 

My thoughts:

Grid Views are more complex to set up, with the benefit of extra flexibility.

If you want to dynamically generate the columns, use a grid view.


Clarification: By "extra flexibility", I meant that you can create your own columns (inheriting from DataControlField), and control every aspect of the cell with business logic of arbitrary complexity.

Come to think of it, the "vanilla" grids are incredibly easy to set up.

Andrew Shepherd
I... I thought it was the other way around... the grid view is the automatic one.
danieltalsky
+2  A: 

Repeaters do not have built in support for sorting, caching, paging or editing. Although they do provide more flexibility when it comes to customizing the markup generated by the control.

Here are some links to more information, the information is about is a little older and outlines the differences between repeaters and data grids but is still useful nonetheless.

Phaedrus
+1  A: 

A grid view can get slapped up automatically with default options and just display a dataset immediately. The grid view has a rich set of automatic controls you can enable like inline editing. It can basically be a complete CRUD system for data without any other code being written than the grid view itself.

However, if you need to do something the grid view control does not do, like if you need to add some very complex multi-field functionality for each record, then it's not too long before you're struggling to hack your functionality into gridview.

In this case, it's far easier to do it manually with a repeater.

danieltalsky