[Mono-list] Binding XML Data to DataList

Marc DM m at phronein.com
Sat Jun 18 13:30:17 EDT 2005


I'm trying to find a nice way to display XML Data in an ASP.NET page
similar to DataBinding web controls like the DataGrid and DataList.

I know I could use DataSet.ReadXml method to import my Xml into a
dataset and then Bind that to the DataGrid but I don't want to convert
the hierarchical data coming from the Xml files into relational data
that will defeat the purpose of using xml. It would also result in me
having to write (and debug) more code. 

I encountered Alex Feinman's blog on the same subject
http://blog.opennetcf.org/afeinman/PermaLink,guid,ca4b6843-8efe-48fd-a9a6-27ca30b947e9.aspx

I downloaded the package and am now trying it out. However, I'm getting
an error which indicates that the XmlDataBinder object is exposing an
XmlElement to the DataList as opposed to exposing the string found at
the XPath string specified.

The error I get is :

  >> Property @href not found in System.Xml.XmlElement

on mono/xsp
and

  >> DataBinder.Eval: 'System.Xml.XmlElement' does not contain a
property with the name @href

on Win2k/.NET 1.1.4322.2032

the ItemTemplate that  throws the error looks like 

<asp:HyperLink runat="server" 
 NavigateUrl=<%
#DataBinder.Eval(((DataListItem)Container).DataItem,"@href") %> >
<asp:Image runat="server" width="200"
ImageUrl=<%
#DataBinder.Eval(((DataListItem)Container).DataItem,"@thumbnail")%>
AlternateText=<%#DataBinder.Eval(((DataListItem)Container).DataItem,
"@caption") + ".jpg"%> />
<br />
<sectionLink><%
#DataBinder.Eval(((DataListItem)Container).DataItem,"@caption")%
></sectionLink>
</asp:HyperLink>

and when creating the XmlDataSource object, the following parameters are
used :

dlg.DataSource = new XmlDataSource(xdoc1.DocumentElement.ChildNodes,
XmlDataSourceMode.DataSourceModeAuto);


Has anyone else tried this or something similar? 

Help ! :(

Marc DM

Kingston, JM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://galactus.ximian.com/pipermail/mono-list/attachments/20050618/d1e2baba/attachment.html


More information about the Mono-list mailing list