ASP.NET XML as Datasource error
Posted
by nekko
on Stack Overflow
See other posts from Stack Overflow
or by nekko
Published on 2010-03-07T23:20:57Z
Indexed on
2010/03/08
0:30 UTC
Read the original article
Hit count: 669
Hello
I am trying to use an XML as a datasource in ASP and then display it as a datagrid. The XML has the following format:
<?xml version="1.0" encoding="UTF-8"?>
<people type="array">
<person>
<id type="integer"></id>
<first_name></first_name>
<last_name></last_name>
<title></title>
<company></company>
<tags>
</tags>
<locations>
<location primary="false" label="work">
<email></email>
<website></website>
<phone></phone>
<cell></cell>
<fax></fax>
<street_1/>
<street_2/>
<city/>
<state/>
<postal_code/>
<country/>
</location>
</locations>
<notes></notes>
<created_at></created_at>
<updated_at></updated_at>
</person>
</people>
When I try to run the simple page I receive the following error
Server Error in '/' Application.
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.
Here is my page code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="shout._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/people.xml" XPath="people/person"></asp:XmlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
DataSourceID="XmlDataSource1">
</asp:GridView>
</div>
</form>
</body>
</html>
Please help. Thanks in advance.
© Stack Overflow or respective owner