ASP.NET: casting XPath for bool - possible?
Hello!
I have an XML value that I would like to use as a boolean to toggle the visibility of a panel. I have something like this:
<asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource">
<ItemTemplate>
<!-- some stuff -->
<asp:Panel id="MyPanel" runat="server" Visible='<%# (bool)XPath("Menu/Show") %>'>
</asp:Panel>
<!-- some more stuff -->
</ItemTemplate>
</asp:FormView>
<asp:XmlDataSource id="MyXmlDataSource" runat="sever" DataFile="MyFile.xml" />
However, this throws an exception. I tried to set the Show value in my XML to "true", "True", "0" but to no avail. Is it possible? My XPath definitely works because I tried to move the <% # (bool) XPath ("Menu / Show")%> outside so that I can see its value, which is correct. I've tried this:
<%#((bool)XPath("Menu/Show")).ToString() %>
But this also throws an exception.
Thank.
0
source to share
5 answers