Monday, December 17, 2007

GridView ,DataList,Repeater,DetailsView,Form VIew and Datasources

Difference between Grid View, Data List, repeater, Details View and Form View

1) Control - Capabilities

GridView - Read/Edit

DataList - Read/Edit

Repeater - Read Only

DetailsView - Read/Edit/Create

FormView - Read/Edit/Create

2)Feature

Repeater

DataList

GridView

Table layout

No

No

Yes

Flow layout

Yes

Yes

No

Column layout

No

Yes

No

Style properties

No

Yes

Yes

Templates

Yes

Yes

Columns/optional

Select/ Edit/Delete

No

Yes

Yes

Sort

No

No

Yes

Paging

No

No

Yes

3) The main difference between DetailsView and FormView is that DetailsView has a built-in tabular rendering, whereas FormView requires a user-defined template for its rendering. The FormView and DetailsView object model are very similar otherwise

4) GRID VIEW
The Gridview is the most used control to display data in a tabular format.
By default it supports major features like sorting, paging.
However it does not support multiple sorting.
DATAGRID control also has a number of new features and advantages over the DataGrid control, which include:
· Richer design-time capabilities.
· Improved data source binding capabilities.
· Automatic handling of sorting, paging, updates, and deletes.
· Additional column types and design-time column operations.
· A Customized pager user interface (UI) with the PagerTemplate property.
DATAGRID
In ASP.NET 2.0, the DataGrid control has been enhanced to support common control features
such as themes and personalization. In addition, the new DataGrid control can be populated
by a data source control. Remember, though, that a DataGrid can only bind to a data source
object for the purpose of reading data. To actually modify the underlying data source,
some user-defined code is still required.
GRIDVIEW
In contrast, the GridView control takes advantage
of the capabilities of the underlying data source and automatically deletes or updates records.
Note that the GridView control also supports the classic binding mechanism based on the
DataSource property and the DataBind method. Although fully supported,
this programming practice is discouraged.

6) Data list relay on Templates
Data list doesn’t have proper structure at designing
But using templates we can provide structure
It doesn’t have in built sorting and Paging

All data source

Data Source ComponentDescription SqlDataSourceThe SQLDataSource accesses data from any relational database (SQL, Oracle, etc/). The main transport protocol is the OLEDB and ODBC data providers and is connected via a connection string.

Caching data via the SqlDataSource control is not enabled by default. To enable it you must set the EnableCaching to true. The CacheDuration property determines the length of time (in seconds) to cache the data.

Specifically for SQL Server Yukon (2005), there is also a cache dependency ( SQLCacheDependency ) feature that caches the database and table (represented as database:table ). Changes made to a table are monitored by change notifications. The user account monitoring the table must have permissions to create tables, stored procedures and more specifically for a table, triggers. Once a change is made, the cache gets updated. This is an extremely important feature to provide high performance data access in your own web application as you can minimize data retrieval to only when the data has been refreshed.

When it comes to updating data you may have the situation where two people may be updating the same record. The SQLDataSource control has a ConflictDetection property that can be either set to CompareAllValues or OverwriteChanges . By default the property is set to OverwriteChanges , which means that each update to a record overwrites the existing data. CompareAllValues allows the developer to code the update/delete method manually. With this option, the control passes the original values within the method which allows you to compare new and old values and determine whether to update or not.

AccessDataSourceThe AccessDataSource inherits from the SqlDataSource , however the Connectionstring and the Provider does not have to be set. As Access databases are file based, it uses the OLEDB - Jet provider to link to this data source by using a physical file location. ObjectDataSourceThe ObjectDatasource allows the data source to bind to a method of a business object (class). This is highly invaluable if applications are designed around a multi-tier architecture.

For the data bind to work successfully the class must have a default constructor and have at least one method that maps to one of the methods defined in the ObjectDataSource control. Namely the, SelectMethod(), UpdateMethod(), InsertMethod() or the DeleteMethod() .

XMLDataSourceThe XML data source either requires an XML file, a URL to the XML representation or a string formatted as XML to perform data binding. This data source is mostly used for hierarchical data.

With the use of XSLT you can transform the XML data to a structure more favorable to bind to your page. By using the TransformFile property of the XMLDatasource this action can be used. However the underlying data will be marked as read-only.

By using XPATH you can retrieve back a subset of your XML Data.

SiteMapDataSourceGets its data from a sitemap source - web.sitemap. It is used for hierarchical data and utilizes the XML format. As an example the site map data can be bound to the tree view or a menu control.

Google