XPath if statement and GridView <ItemTemplate> Problem

Discussion in 'ASP .Net' started by Guest, Oct 31, 2006.

  1. Guest

    Guest Guest


    I have and XMLDataSource which I am using in a GridView control and am
    customizing the grid with <ItemTemplate>. My XML datasource has an element
    with an attribute called "private". I want to check the value of the
    private attribute
    and if is is true, I DON'T want to display this row of data. I am having
    trouble with the XPath expression. How is this done?

    Here is a sample XML source

    <?xml version="1.0"?><comments><comment from="Mike Smith"
    private="false">comment 1</comment><comment from="Joe Doe"
    private="true">comment 2</comment></comments>

    Here is snippet of my page source

    <asp:GridView ID="GridView1" ........
    <b>From: <%# XPath("./@from") %></b><br/>
    Date: <%# XPath("./@date") %><br/>
    Private: <%# XPath("./@private") %><br/> ??? How can I use
    If here
    <%# XPath(".") %><br />

    Any Suggestions? Thanks.
    Guest, Oct 31, 2006
    1. Advertisements

  2. You can use an XSLT transform on your data IIRC. Create an xsl
    stylesheet that outputs copies of all the nodes where private is not
    true and use that as the xsl for the XmlDataSource.
    Flinky Wisty Pomm, Oct 31, 2006
    1. Advertisements

  3. Guest

    Guest Guest


    I don't want to use an xsl stylesheet. Instead I want and should be able to
    do directly in my aspx source. Any ideas on how I can do this from within
    Guest, Oct 31, 2006
  4. Guest

    Guest Guest

    I still can't find an answer to this. Some feedback would be great.
    Guest, Nov 1, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.