0
转换XML我有下面的XML:使用XSLT
<?xml version="1.0" encoding="utf-8" ?>
<ApplicationSettingCategories>
<Category>Cat1</Category>
<Category>Cat2</Category>
<Category>Cat3</Category>
<Category>Cat4</Category>
<Category>Cat5</Category>
<Category>Cat6</Category>
</ApplicationSettingCategories>
我想使用的XmlDataSource和XSLT该XML的下拉列表中ASP.net结合。这是我第一次这样做。 Dropdownlist显示空白项目的正确数量,使我相信迭代正在工作,但值和文本是空白的。
任何帮助确定我的错误,将不胜感激。
感谢
我XLST
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="ApplicationSettingCategories">
<Categories>
<xsl:apply-templates select="Category"/>
</Categories>
</xsl:template>
<xsl:template match="Category">
<Category>
<xsl:attribute name="Category">
<xsl:value-of select="Category"/>
</xsl:attribute>
</Category>
</xsl:template>
我的ASPX
<asp:DropDownList ID="ddl1" runat="server" DataSourceID="XmlDataSource1"
DataTextField="Category" DataValueField="Category" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/Xml/SettingCategory.xml"
TransformFile="~/Schema/AppCategoryXSLT.xslt"></asp:XmlDataSource>
我的源视图
<select name="ddl1" id="ddl1">
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
</select>
太棒了!谢谢。 – Picflight 2009-05-29 23:28:08