473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XPath if statement and GridView <ItemTemplate> Problem

Opa
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.
Oct 31 '06 #1
3 2925
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.

Opa wrote:
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.
Oct 31 '06 #2
Opa

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>

"Flinky Wisty Pomm" wrote:
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.

Opa wrote:
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.

Oct 31 '06 #3
Opa
I still can't find an answer to this. Some feedback would be great.

"Opa" wrote:
>
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>

"Flinky Wisty Pomm" wrote:
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.

Opa wrote:
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.
Nov 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andla Rand | last post by:
Hi, I would like to use this feature but in the codebehind. I'm reading from an example text and everything is not codebehind. I would appreciate if you could help me on this. <form...
3
by: Ben Becker | last post by:
I am trying to build a custom crosstab type of grid where I take some items in a data grid and based on the content of the current item compared to the previous item, determine if a new row in a...
1
by: Jesper Pedersen | last post by:
Hi ! How do I access the following spillerID and Session from another *aspx page in my application? <ItemTemplate> <a href="player_details.aspx?spillerID=<%#...
3
by: webserverpete | last post by:
I would like to have multiple <td> in a repeater control. The below code does not work: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView">...
5
by: Jim in Arizona | last post by:
How do I find a control within a datalist itemtemplate from a sub procedure that isn't a normal called procedure from a datalist (like the update, edit, or cancel procedures)? For instance,...
1
by: =?Utf-8?B?UGF0cmljayBG?= | last post by:
I have a gridview on the page that i want to dynamically populate with radiobuttons, so i went out on the net and found something that works perfectly, it created radionuttons and the postback with...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
3
by: RobertTheProgrammer | last post by:
Hi folks, I've got another problem. Basically, I'm trying to use a nested GridView, however the nexted GridView displays no values (even though in debug I'm getting valid values into my DataSet. ...
0
by: cmrhema | last post by:
Hi, I have a gridview problem while binding more than two gridviews. I am giving a sample scenario of what I have done so far I have two tables First table: Department , having columns...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.