ASP.NET 2- Can't read data in XML file

N

noone

Are there any design criteria for XML files that can be used in Visual Web
Developer.
I'm using XML Control and Dataview control but the page errors with "no
data"
Here's the error when I run the web app
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.
Is there something that I'm missing or is there a bug?


Here's a sample of the XML file
<?xml version="1.0" standalone="yes"?>
<webstats>
<app>
<dir>\\w3svc72802400\\</dir>
<dns>Fbot</dns>
<nbserver>\\fiscmmk410win</nbserver>
<alias>Fbot</alias>
<sname>fiscmmk410win</sname>
<port>80</port>
</app>
</webstats>
 
K

Ken Cox - Microsoft MVP

You need to present your data as attributes rather than as elements to make
that work:

"The XmlDataSource control exposes attributes of XML elements as
data-bindable fields. "

If you can't change the format of the XML, just use an old-fashioned dataset
as shown below.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]



<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim ds As New Data.DataSet
ds.ReadXml(Server.MapPath("app_data/dta.xml"))
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</form>
</body>
</html>


Are there any design criteria for XML files that can be used in Visual Web
Developer.
I'm using XML Control and Dataview control but the page errors with "no
data"
Here's the error when I run the web app
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.
Is there something that I'm missing or is there a bug?


Here's a sample of the XML file
<?xml version="1.0" standalone="yes"?>
<webstats>
<app>
<dir>\\w3svc72802400\\</dir>
<dns>Fbot</dns>
<nbserver>\\fiscmmk410win</nbserver>
<alias>Fbot</alias>
<sname>fiscmmk410win</sname>
<port>80</port>
</app>
</webstats>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top