Saturday, August 9, 2008

Controls in ASP.NET

Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.

This is the most used control in development.
  • A common question is often asked that which control is better and which is to be used?
There are basically 3 most important controls used to display data.
1)Repeater
2)Detail View
3)Datalist
4)Gridview


Repeater
The Repeater control is a data-bound control that uses templates to display data. The Repeater control works by looping through the records in your data source and then repeating the rendering of one of its templates called the ItemTemplate, one that contains the records that the control needs to render.
A Repeater control can be used to build small and Flexible reports with the templates for the items. It supports the following five templates.
  • HeaderTemplate : Can be used to create the Header Rows of the Table data being presented by Repeater control.
  • FooterTemplate : Can be used to create the Footer Rows of the Table data being presented by Repeater control.
  • ItemTemplate : Used for formatting the Items and rows to be displayed.
  • AlternatingItemTemplate : Alternating items formatting.
  • SeparatorTemplate : Styles for separating rows and columns.
Detail View

The DetailsView control is similar to the GridView control with one notable exception—it displays one record at a time. It is a data-bound user interface control that renders a single record at a time from its associated data source, optionally providing paging buttons to navigate between records.
The DetailsView control displays a single record from a data source, where each data row represents a field in the record. It is often used in combination with a GridView control for master/detail scenarios.
The interesting features in detail view are:
  • Automatic paging and sorting with no coding needed
  • Automatic Insert, Update, and Delete capabilities
  • Complete command button functionality (such as the Edit, Update, and Cancel buttons) without any coding
  • Minimal amount of coding involved than in previous versions of the framework
DATALIST

The DataList control like the Repeater control is a template driven, light weight control, and acts as a container of repeated data items. The templates in this control are used to define the data that it will contain. It is flexible in the sense that you can easily customize the display of one or more records that are displayed in the control. You have a property in the DataList control called RepeatDirection that can be used to customize the layout of the control.

The RepeatDirection property can accept one of two values, that is, Vertical or Horizontal. The RepeatDirection is Vertical by default. However, if you change it to Horizontal, rather than displaying the data as rows and columns, the DataList control will display them as a list of records with the columns in the data rendered displayed as rows.

GRIDVIEW

Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.


The GridView control is used to display the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features:

  • Binding to data source controls, such as SqlDataSource.

  • Built-in sort capabilities.

  • Built-in update and delete capabilities.

  • Built-in paging capabilities.

  • Built-in row selection capabilities.

  • Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.

  • Multiple key fields.

  • Multiple data fields for the hyperlink columns.

  • Customizable appearance through themes and styles.














2 comments:

Rem said...

Your blog is very nice...
visit my blog asp.net example

Jen said...

The blog is helpfull...
visit also asp.net [c#]