In my application, I defined an XMLDataSource in the ASPX:
<asp:XmlDataSource ID="XmlThickness" runat="server"
DataFile="~/XML/Data/products.xml" EnableCaching="False"
EnableViewState="False"
></asp:XmlDataSource>
This datasource feeds a grid.
In my code, I set the XPath at a specific point in a specific function, and then issue a new DataBound() on the XMLDataSource, causing the grid to update:
XmlThickness.XPath = "/Item[@label='" + tvwMaterials.SelectedNode.Text + "']/Thickness/Thick";
XmlThickness.DataBind();
All of this works a charm, but when I attempt to read out the XPAth from within a different function, I receive an error message.
XmlNode thick = myDataSource.SelectSingleNode(XmlThickness.XPath.ToString());
Debugging shows the XPath expression actually is empty.
I attempted to move the creation of the DataSource to code, and only then setting the DataSourceID of the grid, but that did not work.
Prior to trying this, I defined a default XPath in the XMLDataSource definition, and at that point, the XMLNode thick
line returned this default string.
I'm a bit confused as to why the XPath is not retained at the XMLDataSource afdter I explicitly set it in the earlier function. Could someone shed some light on this for me, please?