473,769 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><comm ent from="Mike Smith"
private="false" >comment 1</comment><commen t from="Joe Doe"
private="true"> comment 2</comment></comments>

Here is snippet of my page source

<asp:GridView ID="GridView1" ........
<Columns>
<asp:TemplateFi eld>
<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:TemplateFie ld>
</Columns>
</asp:GridView>
Any Suggestions? Thanks.
Oct 31 '06 #1
3 2947
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><comm ent from="Mike Smith"
private="false" >comment 1</comment><commen t from="Joe Doe"
private="true"> comment 2</comment></comments>

Here is snippet of my page source

<asp:GridView ID="GridView1" ........
<Columns>
<asp:TemplateFi eld>
<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:TemplateFie ld>
</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><comm ent from="Mike Smith"
private="false" >comment 1</comment><commen t from="Joe Doe"
private="true"> comment 2</comment></comments>

Here is snippet of my page source

<asp:GridView ID="GridView1" ........
<Columns>
<asp:TemplateFi eld>
<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:TemplateFie ld>
</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><comm ent from="Mike Smith"
private="false" >comment 1</comment><commen t from="Joe Doe"
private="true"> comment 2</comment></comments>
>
Here is snippet of my page source
>
<asp:GridView ID="GridView1" ........
<Columns>
<asp:TemplateFi eld>
<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:TemplateFie ld>
</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
1701
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 runat=server> <asp:DataList id="MyDataList" runat="server" BorderColor="black"
3
2055
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 table should be created or not. In order to do this, I need to have full control over the conditional logic for how items get displayed within a repeater element which I'm not seeing as possible. How can I cursor through a data set, apply...
1
4544
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=<%# DataBinder.Eval(Container.DataItem, "PlayerID") %>" target="_parent"> <%# DataBinder.Eval(Container.DataItem, "playerFirstName") %> <%#
3
2779
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"> <HeaderTemplate> <table> </HeaderTemplate> <tr> <ItemTemplate> <td>
5
12904
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, normally you find a control and access it's properties and methods, like so: Sub Update(ByVal sender As Object, ByVal e As DataListCommandEventArgs) Dim txtPosted As New TextBox
1
3885
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 the works. My problem is that i want to send 2 columns to the gridview instead of 1, but i cant figure out how to add the second column to the gridview. <asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server" ShowHeader="false">...
0
4666
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 and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
3
2651
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. It's probably a binding issue somewhere, but I'm not sure where. Here's the ASP (slightly edited to remove verbosity): <asp:GridView ID="GridViewMain" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" ...
0
1884
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 DeptId and DeptName
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.