XmlDataSource of ASP. NET 2.0

Source: Internet
Author: User

XmlDataSource of ASP. NET 2.0

The SqlDataSource and ObjectDataSource controls are both flat table-based data source controls, and the operations are relatively simple. I will not elaborate on them here.

Here I will talk about the XmlDataSource used to connect the XML file and the SiteMapDataSource used to connect the site navigation data. The XmlDataSource data in the two layers of data source controls is bound together with the flat table control.

The XmlDataSource control allows other controls to be bound to XML data. XmlDataSource supports the DataFile attribute, which is used to specify the path of the XML data file as input. You can also specify the TranformFile attribute to apply XSLT to the data, and set the XPath attribute to specify a subset of the data source nodes to be exposed.

TransformFile = "~ TransXml "XPath =" // User ">

It is also feasible to bind a table-type data binding control to a layered data source, but it can only display the first layer of data. In the demo below, the Repeater control is bound to the temp. xml file. Because the top-level nodes exposed by the data source are nodes, the Repeater can use the Eval Data Binding syntax in its own ItemTemplate template to bind the attributes of these nodes.

Title name:

Email:

In addition to the Eval Data Binding syntax, ASP. NET 2.0 also provides the XPath-based Data Binding syntax, which can be used for any data item that implements the IXPathNavigable interface. Here we will introduce two common expression types:

XPath (expression, [formatString])-calculate the value of the Xpath expression based on the data item and return a single value.

XPathSelect (expression, [formatString])-calculate the Xpath expression value based on the data item and return the node list.

Next, let's take a look at the advantages of using the Xpath data binding method. We can use a demo to describe it.

A Repeater is added to the ItemTemplate of Repeater, and the internal Repeater attribute is bound to an XPathSelect expression describing the Reply subnode of the current User node. In the ItemTemplate template of the internal Repeater, The Xpath data binding expression calculates the value based on these "Reply" content nodes. ASP. NET 2.0 uses this technology to easily construct a rich and hierarchical data display mode by using the combined table format data binding control.

Title ID:

Name:

Email:

Content:

Message ReplyID:

Time:

Content:

  1. Introduction to ASP. net mvc Framework
  2. Introduction to MvcAjaxPanel in ASP. NET MVC
  3. ASP. net mvc Framework to save UpdatePanel
  4. Use ASP. net mvc source code to find a solution
  5. ActionInvoker of ASP. net mvc Framework

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.