Click to See Complete Forum and Search --> : gridview and xmldatasource bug


pschiff
October 16th, 2006, 04:46 PM
hi

I get the following error when I create a gridview and link it to a simple xmldatasource:

there was an error rendering the control.
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.

then when i run the form, i get an exception:
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.

xml:
<?xml version="1.0" encoding="utf-8"?>
<messages>
<message>
<name>Ping Nifty Tools</name>
<text>**** Item started ****</text>
<timeStamp>10-15-2006 18:13:02</timeStamp>
<type>5</type>
<typeText>n/a</typeText>
<status>Unknown</status>
</message>
</messages>

-----------------
<asp:XmlDataSource ID="OpMsgXmlDataSource" runat="server" DataFile="~/App_Data/OP_MSGS.XML">
</asp:XmlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="OpMsgXmlDataSource">
</asp:GridView>


any ideas?

mmetzger
October 18th, 2006, 05:35 PM
It looks like the XmlDataSource will use attributes for Column / Header names in a GridView, where elements are used for TreeNav controls.

To fix your issue, just change the xml file to:


<?xml version="1.0" encoding="utf-8" ?>
<messages>
<message
name="Ping Nifty Tools"
text="**** Item started ****"
timeStamp="10-15-2006 18:13:02"
type="5"
typeText="n/a"
status="Unknown"
/>
</messages>