views:

318

answers:

3

I know GridView control comes with lot of built in functionality, which we can achieve from repeater control. GridView control has performance issues. Why don't we use repeater?

You will be thinking why this question, if you can achieve the functionality and performance using repeater use it, but I want to understand why and when we should use repeater and GridView. Can anybody explain me how and when?

+1  A: 

GridView supports a tablular style of layout. So works nicely for displaying data that would fit into a table. e.g. report style data

Repeater control is good for a more free style layout. Say for displaying products on an ecommerce website or for displaying entries on a forum or blog.

Andrew
+1  A: 

Hi, Like you said, the Repeater can perform certain aspects of the GridView. In this case, you'd want to use a Repeater. However, there are differences between the controls which cannot easily be substituted (or, necessarily, worth the time to implement). You can see a table of differences here. Knowing these differences can make it easier to decide what control to use depending on your needs. (From Link)

The GridView : it supports paging but it doesn't provide a flexible layout , since its mainly used to display the data in a table based layout.And If we looked at data inserting , the Gridview doesn't have a built in support for inserting data( since it doesn't call the insert method of it underlying data source when you click on a button with a CommadName set to "Insert" ).

The Repeater control : you will find that it provides a flexible layout but it doesn't support data grouping ,inserting,deleting , updating and paging through the data .

keyboardP
This is all correct, but I would add one a caveat around the repeater description: paging the data with a repeater control is very quick/easy to do, so I wouldn't use it as a deciding factor.
Nick Craver
+1 Nick, good point.
keyboardP
+1  A: 

The GridView is for tabular data only and does a lot of the work for you, like binding data automatically to columns.

The Repeater gives you more control over the result, but you have to do more because nothing gets binded automatically.

I prefer using a Repeater almost every time, but I can see the usefulness of the GridView.

GoodEnough