ASP. NET Web Forms-Repeater control, formsrepeater

Source: Internet
Author: User

ASP. NET Web Forms-Repeater control, formsrepeater

ASP. NET Web Forms-Repeater control.

The Repeater control is used to display the duplicate list of projects bound to the control.

Bind DataSet to Repeater control

The Repeater control is used to display the duplicate list of projects bound to the control. The Repeater control can be bound to database tables, XML files, or other project lists. Here, we will demonstrate how to bind an XML file to the Repeater control.

In our instance, we will use the following XML file ("cdcatalog. xml "):

Bob Dylan

USA

Columbia

10.90

1985

Bonnie Taylor

UK

CBS Records

9.90

1988

Dolly Parton

USA

RCA

9.90

1982

Gary Moore

UK

Virgin records

10.20

1990

Eros Ramazzotti

EU

BMG

9.90

1997

View the XML file: cdcatalog. xml

First, import the "System. Data" namespace. We need the namespace to work with the DataSet object. Include the following command at the top of the. aspx page:

<% @ Import Namespace = "System. Data" %>

Next, create a DataSet for the XML file and load the XML file into DataSet when the page is loaded for the first time:

TitleArtistCountryCompanyPriceYear

<% # Container. dataItem ("title") %> <% # Container. dataItem ("artist") %> <% # Container. dataItem ("country") %> <% # Container. dataItem ("company") %> <% # Container. dataItem ("price") %> <% # Container. dataItem ("year") %>

Use

You can add an element after the element to describe the appearance of the alternate line in the output. In the following example, the table is displayed with a light gray background every row:

Instance

<% @ Import Namespace = "System. Data" %>

TitleArtistCountryCompanyPriceYear

<% # Container. dataItem ("title") %> <% # Container. dataItem ("artist") %> <% # Container. dataItem ("country") %> <% # Container. dataItem ("company") %> <% # Container. dataItem ("price") %> <% # Container. dataItem ("year") %>

<% # Container. dataItem ("title") %> <% # Container. dataItem ("artist") %> <% # Container. dataItem ("country") %> <% # Container. dataItem ("company") %> <% # Container. dataItem ("price") %> <% # Container. dataItem ("year") %>

Use

An element is used to describe the delimiter between each record. In the following example, a horizontal line is inserted between each table row:

Instance

<% @ Import Namespace = "System. Data" %>

TitleArtistCountryCompanyPriceYear

<% # Container. dataItem ("title") %> <% # Container. dataItem ("artist") %> <% # Container. dataItem ("country") %> <% # Container. dataItem ("company") %> <% # Container. dataItem ("price") %> <% # Container. dataItem ("year") %>

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.