ASP.NET -Repeater控制項

來源:互聯網
上載者:User

ASP.NET -R epeater控制項

Repeater控制項是用來顯示一個重複的項目清單是必然的控制。

一個DataSet綁定到中繼控制
Repeater控制項是用來顯示一個重複的項目清單是必然的控制。 Repeater控制項可綁定到資料庫表,一個XML檔案,或其他的物品清單。在這裡,我們將展示如何結合XML檔案的Repeater控制。

我們將使用下面的XML檔案在我們的例子( “ cdcatalog.xml ” ) :

<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog><cd><title>Empire Burlesque</title><artist>Bob Dylan</artist><country>USA</country><company>Columbia</company><price>10.90</price><year>1985</year></cd><cd><title>Hide your heart</title><artist>Bonnie Tyler</artist><country>UK</country><company>CBS Records</company><price>9.90</price><year>1988</year></cd><cd><title>Greatest Hits</title><artist>Dolly Parton</artist><country>USA</country><company>RCA</company><price>9.90</price><year>1982</year></cd><cd><title>Still got the blues</title><artist>Gary Moore</artist><country>UK</country><company>Virgin records</company><price>10.20</price><year>1990</year></cd><cd><title>Eros</title><artist>Eros Ramazzotti</artist><country>EU</country><company>BMG</company><price>9.90</price><year>1997</year></cd></catalog>
    

看看XML檔案: cdcatalog.xml

首先,進口的“ System.Data ”命名空間。我們需要這種命名與DataSet對象。包括下列指令上方的一個。 aspx頁:

“ % @匯入命名= ” System.Data “ % ”

下一步,建立一個DataSet的XML檔案,並載入XML檔案到DataSet網頁時首先載入:

<script runat="server">sub Page_Loadif Not Page.IsPostBack then  dim mycdcatalog=New DataSet  mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))end ifend sub

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.