By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,548 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,548 IT Pros & Developers. It's quick & easy.

ASP.NET 2.0: problem using xmlDataSource and GridView...

P: n/a
I am having trouble using XML in an ASP.NET 2.0 webform. Using ASP.NET 2.0
beta 2, I have created a blank web page in a C# website. I have added an
XML file (soData.xml), structured as follows:

<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<VFPData>
<ac_sodata>
<iono>Vendor</iono>
<sodate>2004-03-04</sodate>
<sono>164</sono>
<custno>ADG1</custno>
<item>HD10.0G</item>
<descrip>10.0 GB EIDE Ultra DMA 9.0ms Hard Disk Drive</descrip>
<qtyord>0.000000</qtyord>
<qtyshp>75.000000</qtyshp>
<rqdate>2004-03-04</rqdate>
</ac_sodata>
</VFPData>
When I drag an xmlDataSource from the toolbox to the page in Design mode, I
get the following error dialog box:

The operation could not be completed. Unspecified error.

However, if I drag the xmlDataSource from the toolbar onto the page in
Source mode, there is no error. I am able to go into xmlDataSource Tasks
and configure the data file to ~/soData.xml.

Then when I drag a GridView from the toolbox to the page (in either Design
or Source mode), no error is generated. But when I use the GridView Tasks to
set the data source to xmlDataSource1, the GridView box on the page says:

There was an error rendering the control. The data source for the GridView
with id 'GridView1' did not have any properties or attributes from which to
generate columns. Ensure that your data source has content.

I have generated a schema for the XML file, but that doesn't seem to help.
Here is the layout of the .XSD file:

<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VFPData">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="ac_sodata">
<xs:complexType>
<xs:sequence>
<xs:element name="iono" type="xs:string" />
<xs:element name="sodate" type="xs:date" />
<xs:element name="sono" type="xs:unsignedByte" />
<xs:element name="custno" type="xs:string" />
<xs:element name="item" type="xs:string" />
<xs:element name="descrip" type="xs:string" />
<xs:element name="qtyord" type="xs:decimal" />
<xs:element name="qtyshp" type="xs:decimal" />
<xs:element name="rqdate" type="xs:date" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Any help would be greatly appreciated!

Will Kacy
wi**@kacycreative.com
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

I've experienced the same problem and do not know the answer. However,
I've found a couple of workarounds.

Your XML-file contains textnodes and if you change your XML file format
and use attributes instead, it works.

Example:

<users>
<user name="Peter" address="City"></user>
</users>

instead of

<users>
<user>
<name>Peter</name>
<address>City</address>
</user>
</users>

If you don't want to change the XML-file you can make it work if you
write code instead of using the XmlDataSource control:

System.String xmlFile = get_Server().MapPath("XMLfile.xml");
System.Data.DataSet ds_myusers = new
System.Data.DataSet("ds_myusers");
ds_myusers.ReadXml(xmlFile);
GridView1.set_DataSource(ds_myusers);
GridView1.set_DataMember("user");
GridView1.DataBind();

It doesn't answer your question though. I believe it's a bug.

SteenNielsen
--
SteenNielsen
------------------------------------------------------------------------
SteenNielsen's Profile: http://www.hightechtalks.com/m80
View this thread: http://www.hightechtalks.com/t2251064

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.