473,804 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater and XML Node List

Alrighty,

so if I have an XmlNodeList as the data source for a repeater, in my
repeater, I would like to do things like:

<%# DataBinder.Eval (Container.Data Item, "ChildNodes[0].InnerText") %>

But everytime I do it says stuff like:

'System.Xml.Xml ChildNodes' does not allow indexed access.

Of course, it's perfectly happy to use
FirstChild.Next Sibling.InnerTe xt, but I'd like to use indexed methods
or properties, but it does not seem to work.

Here is sample code:

<%@ Page Language="C#" autoEventWireup ="false"%>
<%@ Import Namespace="Syst em.Xml" %>

<script language="c#" runat="server">

override protected void OnInit(EventArg s e)
{
base.OnInit(e);
this.Load += new System.EventHan dler(this.Page_ Load);
}

private void Page_Load(objec t sender, System.EventArg s e)
{
XmlDocument d = new XmlDocument();
d.LoadXml("<roo t><county><id>1 </id><name>FULTON </name><state>GA</state></county><county> <id>2</id><name>DE
KALB</name><state>GA</state></county></root>");

myRepeater.Data Source = d.SelectNodes("//county");
myRepeater.Data Bind();
}

</script>

<html>
<body>

<h2>Counties List</h2>

<asp:Repeater id="myRepeater " runat="server">
<HeaderTemplate >
<table>
<tr><th>ID</th><th>County Name</th><th>State Name</th></tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.InnerText")%> </td>
<td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.I nnerText")%></td>
<td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.N extSibling.Inne rText")%></td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:Repeater>

</body>
</html>
Nov 12 '05 #1
2 10264
How about not using DataBinder.Eval as in:

<%# ((XmlNode)Conta iner.DataItem). ChildNodes[0].InnerText %>

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"William Groombridge" <wi********@hot mail.com> wrote in message
news:fc******** *************** ***@posting.goo gle.com...
Alrighty,

so if I have an XmlNodeList as the data source for a repeater, in my
repeater, I would like to do things like:

<%# DataBinder.Eval (Container.Data Item, "ChildNodes[0].InnerText") %>

But everytime I do it says stuff like:

'System.Xml.Xml ChildNodes' does not allow indexed access.

Of course, it's perfectly happy to use
FirstChild.Next Sibling.InnerTe xt, but I'd like to use indexed methods
or properties, but it does not seem to work.

Here is sample code:

<%@ Page Language="C#" autoEventWireup ="false"%>
<%@ Import Namespace="Syst em.Xml" %>

<script language="c#" runat="server">

override protected void OnInit(EventArg s e)
{
base.OnInit(e);
this.Load += new System.EventHan dler(this.Page_ Load);
}

private void Page_Load(objec t sender, System.EventArg s e)
{
XmlDocument d = new XmlDocument();
d.LoadXml("<roo t><county><id>1 </id><name>FULTON </name><state>GA</state></cou
nty><county><id >2</id><name>DE KALB</name><state>GA</state></county></root>");

myRepeater.Data Source = d.SelectNodes("//county");
myRepeater.Data Bind();
}

</script>

<html>
<body>

<h2>Counties List</h2>

<asp:Repeater id="myRepeater " runat="server">
<HeaderTemplate >
<table>
<tr><th>ID</th><th>County Name</th><th>State Name</th></tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.InnerText")%> </td> <td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.I nnerText")%></td
<td><%# DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.N extSibling.Inne r
Text")%></td> </tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:Repeater>

</body>
</html>

Nov 12 '05 #2
Actually, that works perfect thanks.

Bill G.

"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in message news:<eS******* *******@TK2MSFT NGP11.phx.gbl>. ..
How about not using DataBinder.Eval as in:

<%# ((XmlNode)Conta iner.DataItem). ChildNodes[0].InnerText %>

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"William Groombridge" <wi********@hot mail.com> wrote in message
news:fc******** *************** ***@posting.goo gle.com...
Alrighty,

so if I have an XmlNodeList as the data source for a repeater, in my
repeater, I would like to do things like:

<%# DataBinder.Eval (Container.Data Item, "ChildNodes[0].InnerText") %>

But everytime I do it says stuff like:

'System.Xml.Xml ChildNodes' does not allow indexed access.

Of course, it's perfectly happy to use
FirstChild.Next Sibling.InnerTe xt, but I'd like to use indexed methods
or properties, but it does not seem to work.

Here is sample code:

<%@ Page Language="C#" autoEventWireup ="false"%>
<%@ Import Namespace="Syst em.Xml" %>

<script language="c#" runat="server">

override protected void OnInit(EventArg s e)
{
base.OnInit(e);
this.Load += new System.EventHan dler(this.Page_ Load);
}

private void Page_Load(objec t sender, System.EventArg s e)
{
XmlDocument d = new XmlDocument();

d.LoadXml("<roo t><county><id>1 </id><name>FULTON </name><state>GA</state></cou
nty><county><id >2</id><name>DE
KALB</name><state>GA</state></county></root>");

myRepeater.Data Source = d.SelectNodes("//county");
myRepeater.Data Bind();
}

</script>

<html>
<body>

<h2>Counties List</h2>

<asp:Repeater id="myRepeater " runat="server">
<HeaderTemplate >
<table>
<tr><th>ID</th><th>County Name</th><th>State Name</th></tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%#

DataBinder.Eval (Container.Data Item,"FirstChil d.InnerText")%> </td>
<td><%#

DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.I nnerText")%></td

<td><%#

DataBinder.Eval (Container.Data Item,"FirstChil d.NextSibling.N extSibling.Inne r
Text")%></td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:Repeater>

</body>
</html>

Nov 12 '05 #3

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

Similar topics

0
2428
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an arbitrary number of empty rows to be added to it. So, if a user knew in advance that they wanted to add 3 phone numbers, they can type the nuber '3' in a textbox (outside the repeater) and click a button (also outside of a repeater), and 3 new empty ...
5
8281
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of source code. If you want me to post code, though, just say so. In a nutshell, I've got an ASP.NET application that has one main ASPX page. On that ASPX page, it has a user control (an ASCX) that displays the actual data and controls I need.
1
2328
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has disapeared. The read is done on a button click. I can read the selected items from the other controls in the repeater, demo page here
0
961
by: Ludmal | last post by:
hi I have a xml file and I want to bind it to a nested repeaters. but the problem I'm having is now I cannot give reference to xml nodes inside the repeater.. pls advice me .. the problem is in line 17. It's not able to render the CountrName from the tblCoutry xml node.. any idea's..????? HTML with line numbers --------------------------------- 01) <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"...
4
4162
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so at compile time I don't know what text boxes are going to be present at run time. This is where it seems the FindControl method would be come into play. I loop through a list of control (all textboxes) names I created on page load and see if they...
0
1119
by: jackson | last post by:
I'm very, very new to ASP.NET - but have been trying to learn on my own... I'm currently attempting to move my company's website over to a ASP.NET website and am running into an issue. Because not all browsers support the :first-child/last-child psuedoclass I have to assign a CSS class of "firstchild/lastchild" to HTML tags for their respective position (i.e. in a list). This is so I can control their appearance on the page when needed....
2
1316
by: champ.supernova | last post by:
I have a repeater, which contains in its <HEADERTEMPLATEa drop-down list (set to autopostback). If the page is a postback, I want to modify the SQL of the repeater's datasource, DEPENDING ON the value of the drop-down list. However, I can't evaluate the drop-down list submission at Page_Load, because the repeater has not yet been databound or rendered, so effectively the drop-down list doesn't yet exist.
0
1126
by: Csharprookie | last post by:
I am trying to create an array list (like follows) public static ArrayList GetVehicleInfo(int vehicleId, int quoteId) { ArrayList AllVehicles = new ArrayList(); I have the ArrayList delcared as follows for use in a repeater. protected ArrayList AllVehicles = new ArrayList();
4
307
by: Ahmd | last post by:
I have a Repeater to which a sitemap is bound, i want to remove or hide any node while form load <asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSource1" EnableViewState="False"> <ItemTemplate> <li> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></ asp:HyperLink>
0
10352
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
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
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
6867
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
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
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.