Del via


ASP.NET Data Access Overview

Web applications commonly access data sources for storage and retrieval of dynamic data. You can write code to access data using classes from the System.Data namespace (commonly referred to as ADO.NET) and from the System.Xml namespace. This approach was common in previous versions of ASP.NET.

However, ASP.NET also enables you to perform data binding declaratively. This requires no code at all for the most common data scenarios, including:

  • Selecting and displaying data.

  • Sorting, paging, and caching data.

  • Updating, inserting, and deleting data.

  • Filtering data using run-time parameters.

  • Creating master-detail scenarios using parameters.

ASP.NET includes two types of server controls that participate in the declarative data binding model: data source controls and data-bound controls. These controls manage the underlying tasks required by the stateless Web model for displaying and updating data in ASP.NET Web pages. As a result, you are not required to understand details of the page request lifecycle just to perform data binding.

Data Source Controls

Data source controls are ASP.NET controls that manage the tasks of connecting to a data source and reading and writing data. Data source controls do not render any user interface, but instead act as an intermediary between a particular data store (such as a database, business object, or XML file) and other controls on the ASP.NET Web page. Data source controls enable rich capabilities for retrieving and modifying data, including querying, sorting, paging, filtering, updating, deleting, and inserting. ASP.NET includes the following data source controls:

Data source control

Description

AccessDataSource

Enables you to work with a Microsoft Access database.

For more information, see AccessDataSource Web Server Control Overview.

LinqDataSource

Enables you to use Language-Integrated Query (LINQ) in an ASP.NET Web page through declarative markup in order to retrieve and modify data from a data object. Supports automatic generation of select, update, insert, and delete commands. The control also supports sorting, filtering, and paging.

ObjectDataSource

Enables you to work with a business object or other class and create Web applications that rely on middle-tier objects to manage data.

For more information, see ObjectDataSource Web Server Control Overview.

SiteMapDataSource

Used with ASP.NET site navigation. For more information, see ASP.NET Site Navigation Overview.

SqlDataSource

Enables you to work with ADO.NET managed data providers, which provide access to Microsoft SQL Server, OLE DB, ODBC, or Oracle databases.

For more information, see SqlDataSource Web Server Control Overview.

XmlDataSource

Enables you to work with an XML file, which is especially useful for hierarchical ASP.NET server controls such as the TreeView or Menu control.

For more information, see XmlDataSource Web Server Control Overview.

Data-source controls can also be extended to support additional data access storage providers.

For more information on data source controls, see Data Source Controls Overview.

Data-bound Controls

Data-bound controls render data as markup to the requesting browser. A data-bound control can bind to a data source control and automatically fetch data at the appropriate time in the page request lifecycle. Data-bound controls can take advantage of the capabilities provided by a data source control including sorting, paging, caching, filtering, updating, deleting, and inserting. A data-bound control connects to a data source control through its DataSourceID property.

ASP.NET includes the data-bound controls described in the following table.

Note

The DataGrid control available in ASP.NET version 1.0 and version 1.1 has been superseded by the GridView control, which includes expanded capabilities for sorting, paging, and modifying data. Existing pages that use the DataGrid control will continue to function. As with other data controls, the DataGrid control has been enhanced to interact with data source controls.

Note

The ListView control supersedes the Repeater control and the DataList control. Existing pages that use those controls will continue to function. The ListView control simplifies the implementation of many common scenarios.

For more information, see ASP.NET Data-Bound Web Server Controls Overview.

LINQ

Language-Integrated Query (LINQ) provides a unified programming model for querying and updating data from different types of data sources, and extends data capabilities directly into the C# and Visual Basic languages. LINQ applies the principles of object-oriented programming to relational data. To work with LINQ, you can use the LinqDataSource control. You can also create LINQ queries directly in order to access data from a Web page. For more information, see Using LINQ with ASP.NET.

Dynamic Data

ASP.NET Dynamic Data is a framework that enables you to create data-driven ASP.NET Web applications quickly. Dynamic Data automatically discovers the data model at run time and determines UI behavior from the data model. A scaffolding framework instantly provides a functional Web site for displaying and editing data. This scaffolding can then be customized using metadata, templates, or by creating standard ASP.NET pages to override the default behavior. Existing ASP.NET Web applications can easily integrate pieces of the scaffolding logic into their web pages. For more information about Dynamic Data, see Using ASP.NET Dynamic Data

See Also

Concepts

Data Source Controls Overview

ASP.NET Data-Bound Web Server Controls Overview