问候!
我有一个使用 XmlDataSource 控件的 Repeater 控件。
<asp:FormView id="myFormView" runat="server" DataSourceID="myXmlDataSource">
<ItemTemplate>
<span>Items</span>
<asp:Repeater id="myRepeater1" runat="server" DataSource='<%# XPathSelect("Items/*")%>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><%# XPath("text()")%></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
<span>Things</span>
<asp:Repeater id="myRepeater2" runat="server" DataSource='<%# XPathSelect("Things/*")%>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><%# XPath("text()")%></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:FormView>
<asp:XmlDataSource ID="myXmlDataSource" XPath="Root" EnableCaching="false" runat="server" />
XML 看起来像这样:
<Root>
<Items>
<Item>A</Item>
<Item>B</Item>
<Item>C</Item>
<Item>D</Item>
</Items>
<Things>
<Thing>1</Thing>
<Thing>2</Thing>
<Thing>3</Thing>
</Things>
</Root>
在某些情况下,我想在绑定时“跳过”“B”项,使其不显示。在 DataBinding 事件期间有没有办法可以跳过“B”项的绑定以使其不显示?