Forget it. I've already started to rewrite the thing using the System.Web.UI.WebControls.Xml control in place of the Datalist/grid.

the XSLT code to do the transform is much simpler imho than the DataBinding code needed to create the DataSource and bind to the datalist.

It was a bad idea to begin with.

MDM

On Sat, 2005-06-18 at 12:30 -0500, Marc DM wrote:
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
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to