Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ASP.NET 2- Can't read data in XML file

Reply
Thread Tools

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

 
 
noone
Guest
Posts: n/a
 
      04-01-2006
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>

 
Reply With Quote
 
 
 
 
Ken Cox - Microsoft MVP
Guest
Posts: n/a
 
      04-03-2006
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>


"noone" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
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>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File.read(fname) vs. File.read(fname,File.size(fname)) Alex Dowad Ruby 4 05-01-2010 08:20 AM
Read xml file and write data to a txt file using PERL.... urgent Ram Perl Misc 3 04-26-2007 12:23 PM
How to read from a file, stored the data in an array, and return number of records read back to main tyeung168@gmail.com C++ 2 02-27-2007 07:12 AM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM



Advertisments