XPath if statement and GridView <ItemTemplate> Problem

G

Guest

Hi,

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" ........
<Columns>
<asp:TemplateField>
<ItemTemplate>
<b>From: <%# XPath("./@from") %></b><br/>
Date: <%# XPath("./@date") %><br/>
Private: <%# XPath("./@private") %><br/> ??? How can I use
If here
<%# XPath(".") %><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


Any Suggestions? Thanks.
 
F

Flinky Wisty Pomm

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.
 
G

Guest

Hi,

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
<ItemTemplate>
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top