Asp.net 2.0 tutorial Data Source Control 2

Source: Internet
Author: User
Tags xsl file

Respect the author. Keep the words www.it55.com.

The previous section describes important members of the sqldatasource and accessdatasource. NET data source controls. This section describes the xmldatasource control, sitemapdatasource control, and objectdatasource control in the. NET data source control.

1. xmldatasource Control
The xmldatasource control is designed for the XML in hierarchical data sources. Hierarchical Data Sources also include expanded folder lists and website maps.
Create method: drag the xmldatasource control in the "data" option bar on the left side of vs2005 to the design interface on the. ASPX page. Using the "configure data source" menu in the "xmldatasource task" setting box, we can set the data source of the xmldatasource control:



The XML Path is used to assign values to the datafile attribute of the xmldatasource control, the transformation file path to the transformfile attribute, and the XPath attribute to the XPath attribute.

What is XML?
To put it simply, the code of http://www.itgao.com/rssfeed.aspxcontains xmlcontent (only the extension is changed from. XML to. aspx ).
For XML Information, see: http://www.itgao.com/html/2007-05/45447.html

What is a conversion file?
The XSL file is also an XML file, and its content specifies how to convert XML data. Among them, foreach is obviously a program loop ., Just like using CSS, only one row is added to the second row in the XML file. <? XML-stylesheet type = "text/XSL" href = ".../simple. XSL"?>
More information: http://www.itgao.com/search.aspx? Keyword = XSLT % C7 % E1 % CB % C9 % C8 % EB % C3 % C5 & where = title

What is XPath?
XPath is a query language used to retrieve information contained in XML document nodes. In this example ".
For information about XPath, see: http://www.itgao.com/html/2007-04/17096.html

The xmldatasource control has very few properties, so it is easy to configure.

2. sitemapdatasource Control
Are you familiar with this name? We learned in front of the site navigation controls (http://www.itgao.com/html/2007-05/45404.html) more than once used, so its use method is no longer tired. Here we will only talk about its application scope and precautions:
The sitemapdatasource control is a data source control used by ASP. NET 2.0 to connect to and Access Site Map Files (*. sitmap. You can also directly apply the accessed data to the website navigation control. Of course, there are other controls.
Below are some of its common attributes:
Showstartingnode: bool value, used to configure whether the sitemapdatasource control displays the root node in the node tree.
Startingnodeurl: This attribute sets the node from which the sitemapdatasource control should start.
Startfromcurrentnode: bool value, used to set whether to read data of the node and Its subnodes from the node location of the current page.
Startingnodeoffset: an integer used to set the offset of the Start Node. The default value is 0. If it is set to-1, data is read from the parent node; if it is 1, data is read from the child node. And so on.
The sitemapdatasource control does not support data caching, sorting, filtering, paging, addition, deletion, and modification supported by most data source controls.

3. objectdatasource Control
Some people say that the objectdatasource control is made up of the N-layer architecture of the program. The analogy is quite vivid and of course not without reason. The following is an article about the n-layer architecture. It is recommended that you read more about the architecture:
Three-tier architecture: http://www.itgao.com/html/2007-05/45448.html
N-layer system architecture design should consider several aspects: http://www.itgao.com/html/2007-05/45449.html
Figure: three-tier architecture

The objectdatasource control is different from other data source controls. It helps developers build a bridge between the presentation layer and the data access layer and the presentation layer and the business logic layer, in this way, data objects from the data access layer or business logic layer are bound to the data binding control in the presentation layer for data display and editing.
To create the objectdatasource control, drag and drop the objectdatasource control from the "data" option bar on the left side of vs2005 to the design interface on the. ASPX page. At this time, we will find that the objectdatasource control and sqldatasource control have many different attributes. The objectdatasource control does not have connectionstring, providername, selectcommand, and other attributes. It is replaced by typename, selectmethod, and other attributes. These new attributes are used to indicate the business class used by the objectdatasource control instance and the method used to retrieve or edit data. These business classes and methods come from the data access layer or business logic layer.
Let's take a look at the Declaration Code of the objectdatasource control:
<Asp: objectdatasource id = "objectperformance1" runat = "server" typename = "componentclassname" selectmethod = "getrecords"> </ASP: objectdatasource>
In the code, the typename attribute is used to set the name of the relevant service class; The selectmethod attribute is used to set the method name for retrieving data from the service class. The business class method must return an enumerated list object, such as a set, array, dataset, or datareader, or a business entity object containing data.
In addition, the objectdatasource control has attributes such as insertmethod, updatemethod, and deletemethod. The attribute value is still the method name in the service class.

The objectdatasource control is an excellent part of Asp.net 2.0, but it is also a complicated part. It has a large number of attributes, and there are a lot of events and methods. I don't want to study them here. Let's just look at msdn. # P # paging title # e #
Objectdatasource control specific use of our subsequent tutorials will be contacted multiple times, so here only describes his operating mechanism and Some Properties, not to mention, related examples please refer to: http://www.itgao.com/html/2007-05/45455.html

So far, we have completed the initial contact with the Asp.net data source controls and are familiar with their creation methods and some attributes. For how they work in a program by using data binding controls, see the following section: ASP. NET 2.0 data binding controls

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.