2012-03-25 107 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