Several Posts w/o Reply - Can Anyone Help Me???

I thought that my question would have a quick and simple answer from someone in this forum, but I have yet to receive one response from either the .NET forum or the XML forum on this subject. So here it goes:

How can I pull data from a child element of an XML file into an ASP.NET Web Control (i.e. DataGrid, DataList, or Repeater)?

For instance, this would be the simple XML file:
<root>
<element>
<childelement>
</childelement>
</element
</root>
...and this would the the ASP.NET web control (I'm using a Repeater in this example):
<%@ Page Language="VB" Debug="true" EnableSessionState="false" %>
<%@ import Namespace="System.Data" %>
<script runat="server">

'Pulls "Administration Dept." data
Sub Page_Load
If Not Page.IsPostBack then
Dim xmlAD = New DataSet
xmlAD.ReadXml("http://SERVERNAME/FILENAME.xml")
aspxAD.DataSource = xmlAD
aspxAD.DataBind()
End If
End Sub

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//Ddiv HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.ddiv">
<html>
<head>
<title>PAGETITLE</title>
</head>
<body>
<form runat="server">
<asp:Repeater id="aspxAD" runat="server">
<HeaderTemplate>
##header##
</HeaderTemplate>
<ItemTemplate>
<div>Element: <%#Container.DataItem("element")%>
</div>
<div>Child Element: <%#Container.DataItem("childelement")%>
</div>
</ItemTemplate>
<FooterTemplate>
##footer##
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>

...which results in this error message:
Server Error in '/' Application.
childelement is neither a DataColumn nor a DataRelation for table root.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: childelement is neither a DataColumn nor a DataRelation for table root.

Please, someone help me to see the light on this one...I beg of you.sorry about the lack of replies. I do not use xml extensively myself for data storage. But tomorrow I will poke around 4guysfromrolla and see if I can dig into some of their code in their articles (I'll probably take a gander at msdn too) and see if I can find what they are doing differently.Thanks PeOfEo! I appreciate the timely response, and hope to hear from you soon.It looks like if you just use a datacolumn instead of a dataset that should solve your problem.

actually I found this and it should help
<!-- m --><a class="postlink" href="http://aspnet.4guysfromrolla.com/articles/052902-1.aspx">http://aspnet.4guysfromrolla.com/articles/052902-1.aspx</a><!-- m -->
 
Back
Top