ASP. NET data access

Source: Internet
Author: User

Web ApplicationsProgramGenerally, you can access data sources used to store and retrieve dynamic data. You can writeCodeTo access data using classes in the system. Data namespace (usually called ADO. net) and system. xml namespace. This method is common in earlier versions of ASP. NET.

However, ASP. NET also allows you to perform data binding as declared. In most common data solutions that include the following solutions, this method does not require any code at all:

    • Select and display data.

    • Sort, pagination, and cache data.

    • Update, insert, and delete data.

    • Filter data using runtime Parameters

    • Use parameters to create a master/detail solution.

ASP. NET includes two types of server controls involved in the declarative data binding model: data source controls and data binding controls. These controls manage the basic tasks required to display and update data on the ASP. NET web page in the Stateless web model. Therefore, you do not need to know the detailed information of the page request lifecycle to perform data binding.

The data source control is an ASP. Net control that manages tasks such as connecting to the data source and reading and writing data. The data source control does not present any user interface, but acts as the intermediary between a specific data source (such as a database, business object, or XML file) and other controls on the ASP. NET web page. The data source control provides rich data retrieval and modification functions, including query, sorting, paging, filtering, update, deletion, and insertion. ASP. NET includes the following data source controls:

Accessdatasource

Allows you to process Microsoft Access databases.

Linqdatasource

With this control, you can use the language Integrated Query (LINQ) in the ASP. NET web page to check and modify data from data objects. Supports automatic generation of selection, update, insertion, and deletion commands. This control also supports sorting, filtering, and paging.

Objectdatasource

Allows you to use business objects or other classes and create Web applications that rely on intermediate layer objects to manage data.

Sitemapdatasource

It is used in combination with ASP. NET site navigation.

Sqldatasource

Allows you to process ADO. Net-hosted data providers that provide access to Microsoft SQL Server, OLE DB, ODBC, or Oracle databases.

Xmldatasource

Allows you to process XML files. This XML file is extremely useful for hierarchical ASP. NET Server controls such as Treeview and menu controls.

 

You can also extend the data source control to support other data access storage providers.

 

Data Binding Control

The data binding control presents the data as a tag to the browser requesting the data. The data binding control can be bound to the data source control and automatically obtain data at the appropriate time of the page request lifecycle. The data binding control can use the functions provided by the data source control, including sorting, paging, caching, filtering, updating, deleting, and inserting. The data binding control connects to the data source control through its performanceid attribute.

ASP. NET includes the data binding controls described in the following table.

List controls

Displays data in various lists. List controls include bulletedlist, checkboxlist, dropdownlist, ListBox, and radiobuttonlist controls.

Adrotator

The advertisement is displayed as an image on the page. You can click the image to go to the URL associated with the advertisement.

Datalist

Displays data in the form of a table. Each item is presented using the template you defined.

Detailsview

Displays a record at a time in a table layout and allows you to edit, delete, and insert records. You can also read multiple records.

Formview

Similar to the detailsview control, you can define an automatic layout for each record. For a single record, the formview control is similar to the datalist control.

 

Gridview

Displays data in the form of tables, and supports editing, updating, deleting, sorting, and paging data without writing code.

Listview

This allows you to use templates to define data la S. Supports automatic sorting, editing, insertion, and deletion. You can also enable paging by using the associated datapager control.

Menu

Present data in Hierarchical Dynamic menus that can include sub-menus.

For more information, see menu Web Server Control.

Repeater

Displays data in the form of a list. Each item is presented using the template you defined.

For more information, see repeater Web Server Control.

Treeview

Data can be displayed in the form of a layered tree of expanded nodes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.