Latest updates

[5]

Difference between Repeater vs. DataList vs. ListView vs. GridView vs. DetailsView vs. FormView


Repeater vs. DataList vs. ListView vs. GridView vs. DetailsView vs. FormView

                                         Comparasion Table:

Control
Insert
Update
Delete
Paging
Sorting
 Grouping                
Gridview
Yes
Yes
Yes
Yes
Yes
No
ListView
Yes
Yes
Yes
Yes
Yes
Yes
DataList
Yes
Yes
Yes
No
No
No
DetailsView
Yes
Yes
Yes
Yes
No
Single Record:Yes
FormView
Yes
Yes
Yes
Yes
No
Single Record:Yes
Repeater
No
No
NO
No
No
Single Record:Yes



Repeater control
Repeater control is derived from Control class.
It was introduced with Asp.Net 1.0.
Repeater simply repeats data given in templates. Repeated data is usually HTML code mixed with records from data source.
Repeater's output is not predefined. Because of that, Repeater demands most work to define template. In return it gives us most flexibility to build layout and optimize presentation.
With same template and same data set, Repeater usually works faster of DataList or GridView controls. This is mostly because of DataReader class, which is used for read only access. DataReader is faster than DataSet or DataTable classes commonly used with GridView.
Compared to GridView and DataList control, Repeater has limited features. By default, Repeater is good for displaying of data. It is not best choice if you need editing of data. Also, by default it doesn't provide paging and sorting of records.

DataList control
Unlike Repeater, DataList control is derived from WebControl class. That gives it a number of style properties like BorderStyle, BackColor, ForeColor etc.
DataList is somewhere between Repeater and GridView, in many ways looks like a compromise between these two. 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. These properties are useful when you need to create presentation with more than one record per row, like image gallery, product catalog etc. For example, let say you are creating an image gallery and want to show 5 images per row. Repeater would require checking of record position and manipulating HTML. With DataList, just use RepeatDirection="Horizontal" and RepeatColumns="5".
RepeatLayout could be Table or Flow, depending of do you need HTML table structure in layout.

GridView control
Like DataList control, GridView is derived from WebControl class and includes numerous style properties. It was introduced with Asp.Net 2.0.  In addition to this, GridView is most complex control and have most properties. Numerous features include data paging, sorting, updating and deleting of records. First versions of ASP.NET had DataGrid control. GridView is replaced DataGrid in ASP.NET 2.0 as improved version of old DataGrid control.
GridView displays data in form of grid. Rows and columns are represented as HTML table. This is very useful if you need grid-like presentation. If you need to present data in table layout, then GridView requires a minimum of effort. In same time, if you want more customizable flow layout, GridView is not best option.
Common problem when using GridView control could be large ViewState which makes page loads slower and requires more bandwidth. This could be insignificantly on low traffic website, but keep in mind that for each second while the page loads, the percentage of visitors will become impatient and leave website. Also, massive view state is not good for SEO (search engine optimization).
One more problem is using of default pager on large tables or high traffic websites. If default paging is used, GridView will load complete dataset in memory, which descreases website's performances.

DetailsView control

The DetailsView control is typically used for updating and inserting new records often in a master/detail scenario. In such a scenario, the selected record of the master control (GridView or ListBox control) determines the record to be displayed in the DetailsView control. For instance, in an ERP application, we use the GridView control to display pending sales order details and the DetailsView control to display the selected single sales order details. We use the <BoundField> elements or <TemplateField> elements to render the DetailsView control. The DetailsView control displays each field of a record as a table row.

ListView control
ListView control is newest data presentation control, introduced in ASP.NET 3.5. Previous controls (Repeater, DataList and GridView) logically follow each other. For example, Repater is simplest but fastest, then DataList has more features but more overheads too, and finally GridView is most complex, has most features, but heaviest and thus slowest on page.
Now, there is new ListView control which tries to provide best from both sides: speed and flexibility in design, and also a lot of features like paging, updating or deleting of records etc. Because of this, ListView control is often better choice than Repeater or DataList.
Flexibility in design comes with price. To use ListView, you'll probably have to write a lot of markup code. For simple table layout, GridView requires much less work.
ListView has new LayoutTemplate. Instead of Header and Footer templates, ListView has just LayoutTemplate. Main advantage of LayoutTemplate when compared to Header and Footer templates is that LayoutTemplate makes markup code looks more object oriented. So, it is not a big difference between these two models. It is possible to achieve same results with LayoutTemplate on ListView like with HeaderTemplate and FooterTemplate on Repeater, DataList and GridView.

FormView control

The FormView control is designed to display a single data item (single database record) from a data source, for example Sql server database. Unlike the DetailsView control, templates have to be used in the FormView control to display data. The FormView control renders all fields of a single record in a single table row. While using templates, we can place any control such as dropdownlist, checkbox and even we can place tables and rich control like GridView etc. Compared to the DetailsView control, the formView control gives more flexibility over the rendering of fields. This form of rendering data enables more control over the layout of the fields. Using the FormView control is more complex as compared to the DetailsView control. Note that we cannot use <BoundField> elements to render the FormView control.

Difference between Repeater vs. DataList vs. ListView vs. GridView vs. DetailsView vs. FormView Difference between Repeater vs. DataList vs. ListView vs. GridView vs. DetailsView vs. FormView Reviewed by Admin on 08:04:00 Rating: 5

No comments:

Sora Templates