I am trying to make a simple grid view that is binded to a simple xml document but I must be missing something since I am keep getting error message:
The data source for GridView with id
'GridView1' did not have any
properties or attributes from which to
generate columns. Ensure that your
data source has content.
Code
<asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1">
<Columns>
<asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" />
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="Notifications.xml" XPath="/data/node"></asp:XmlDataSource>
XML
<?xml version="1.0" encoding="utf-8" ?>
<data>
<node>
<id>1096</id>
<name>About Us</name>
<date>21/12/2009 17:03:43</date>
<user id="1">writer</user>
</node>
<node>
<id>1099</id>
<name>News</name>
<date>21/12/2009 17:03:47</date>
<user id="1">writer</user>
</node>
<node>
<id>1098</id>
<name>Another page</name>
<date>21/12/2009 17:03:52</date>
<user id="1">writer</user>
</node>
</data>
Is it perhaps my xpath that is wrong or am I making something fundamentally wrong here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…