What are the Differences between DataGrid, DataList and Repeater ?
DataGrid, DataList and Repeater
Hi
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 19, 2012, 1:36 AM
Similarities:
They are all ASP.NET data Web controls.
They have common properties like
DataSource Property
DataBind Method
ItemDataBound
ItemCreated
When the DataSource Property of a Datagrid is assigned to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem.
Difference:
Datagridelement created for the particular DataRow and is a tabular representation with Columns and Rows. Datagrid has a in-built support for Sort, Filter and paging the Data.
The HTML code generated has an HTML TABLE
Datalist
An Array of Rows and based on the Template Selected and the RepeatColumn Property value The number DataSource records that appear per HTML
Repeater Control
The Datarecords to be displayed depend upon the Templates specified and the only HTML generated accordingly. Repeater does not have in-built support for Sort, Filter and paging the Data.
DataGrid and DataList controls are derived from the WebControl class, while the Repeater control is derived from the Control class. The WebControl class contains a number of aesthetic properties, such as BackColor, ForeColor, CssClass, BorderStyle and so on.
In ASP .NET basically there are three kinds of the Data Presentation Controls.
- GridView or DataGrid
- DataList
- Repeater
List of different abilities of Repeater Control, Datalist Control and GridView Control features.Features of a GridView:
- Alternate item
- Header
- Footer
- Colors, font, borders, etc.
- Paging
Features of Repeater:- List format
- No default output
- More control
- More complexity
- Item as row
- Not updateable
Features of DataList:- Directional rendering
- Good for columns
- Item as cell
- Alternate item
- Updateable
Difference between Datagrid,DataList and Data Repeater:- Datagrid has paging while Datalist doesnt.
- Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.
- A repeater is used when more intimate control over html generation is required.
- When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than a Datagrid.
The Repeater repeats a layout of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you're working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default.GridView example:
DataList Example:
DataList in ASP.NET using C#
DataSourceID="SqlDataSource1"
Font-Bold="True" Font-Names="Verdana" Font-Size="Small" GridLines="Both" RepeatColumns="2"
RepeatDirection="Horizontal" Width="463px">
Student Information
Name:
DOB:
Age:
Course:
Branch:
City:
MobileNo:
SelectCommand="SELECT * FROM [Student]">
Repeater Example:
<%# DataBinder.Eval(Container.DataItem, "TestEnglish") %>
<%# DataBinder.Eval(Container.DataItem, "TestMath") %>
******
<%# DataBinder.Eval(Container.DataItem, "TestEnglish") %>
<%# DataBinder.Eval(Container.DataItem, "TestMath") %>
End of the funky stuff
SelectCommand="SELECT * FROM [Student]">
Please refer the below link
http://24x7aspnet.blogspot.in/2009/06/feature-difference-between.html
Thanks