2012-03-25 213 views
0
<asp:XmlDataSource ID="XmlDataSource2" runat="server" 
      DataFile="~/App_Data/XMLFile1.xml" TransformFile="XSLTFile1.xslt"></asp:XmlDataSource>   
     <asp:DropDownList ID="DropDownList1" runat="server" 
      DataSourceID="XmlDataSource2" DataTextField="author" 
      DataValueField="author" 
      onselectedindexchanged="DropDownList1_SelectedIndexChanged" 
      AutoPostBack="True"> 
     </asp:DropDownList> 

<?xml version="1.0"?> 
<catalog> 
    <book id="bk101"> 
    <author>Gambardella, Matthew</author> 
    <title>XML Developer's Guide</title> 
    <genre>Computer</genre> 
    <price>44.95</price> 
    <publish_date>2000-10-01</publish_date> 
    <description> 
     An in-depth look at creating applications 
     with XML. 
    </description> 
    </book> 
    <book id="bk102"> 
    <author>Ralls, Kim</author> 
    <title>Midnight Rain</title> 
    <genre>Fantasy</genre> 
    <price>5.95</price> 
    <publish_date>2000-12-16</publish_date> 
    <description> 
     A former architect battles corporate zombies, 
     an evil sorceress, and her own childhood to become queen 
     of the world. 
    </description> 
    </book> 
    <book id="bk103"> 

我從XML加載到下拉列表所有作者的
列表
問題是這不是明顯感到歌廳更多然後每個作者的一個
如何使這個下拉列表不同??
我tryed谷歌一下,發現的SelectCommand,但我不能得到它的工作
它似乎像一個SQL查詢,但我不知道在這裏
希望有人能幫助:)下拉列表

回答

0

不知道這將爲你工作,但是你可以指定Xml數據源的XPath屬性:XPath =「// author [not(。= preceding :: author)]」。

<asp:XmlDataSource ID="XmlDataSource2" runat="server" 
      DataFile="~/App_Data/XMLFile1.xml" XPath="//author[not(.=preceding::author)]"></asp:XmlDataSource>  
+0

好吧,它的工作模式xpath是有點,但它的作品:)/* /書[不(@author =之前 - 兄弟::書/ @作者)] – user1246950 2012-03-27 21:09:25