This is a migrated thread and some comments may be shown as answers.

XmlDocument DataBind

1 Answer 84 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Colin M
Top achievements
Rank 1
Colin M asked on 22 May 2008, 08:44 AM
Hi

I am trying to bind a chart to a Xml Document object but have been unable to get it working successfully.

I am following the example in the documentation for binding to an Xml file and this is working without problem.

RadChart1.DataSource = Server.MapPath("~/Products.xml"); 
RadChart1.Series[0].DataYColumn = "QuantityInStock"
RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"
RadChart1.DataBind(); 

However if I attempt to bind to an XML document I am getting the following error "Column 'IsEmpty' does not belong to table". 

I am using the following code to build the Xml document:
StringBuilder sb = new StringBuilder(); 
StringWriter sw = new StringWriter(sb); 
XmlTextWriter writer = new XmlTextWriter(sw); 
 
writer.Formatting = Formatting.Indented; 
 
writer.WriteStartDocument(); 
writer.WriteStartElement("Products"null); 
 
writer.WriteStartElement("Product"null); 
writer.WriteAttributeString("Name""Parka L"); 
writer.WriteAttributeString("QuantityInStock""123"); 
writer.WriteEndElement(); 
 
writer.WriteStartElement("Product"null); 
writer.WriteAttributeString("Name""Parka M"); 
writer.WriteAttributeString("QuantityInStock""56"); 
writer.WriteEndElement(); 
 
writer.WriteStartElement("Product"null); 
writer.WriteAttributeString("Name""Parka S"); 
writer.WriteAttributeString("QuantityInStock""92"); 
writer.WriteEndElement(); 
 
writer.WriteStartElement("Product"null); 
writer.WriteAttributeString("Name""Mittens"); 
writer.WriteAttributeString("QuantityInStock""12"); 
writer.WriteEndElement(); 
 
writer.WriteEndElement(); 
writer.Flush(); 
 
XmlDocument xmlDocs = new XmlDocument(); 
xmlDocs.LoadXml(sb.ToString()); 
 
RadChart1.DataSource = xmlDocs; 
RadChart1.Series[0].DataYColumn = "QuantityInStock"
RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"
RadChart1.DataBind(); 

Any suggestions as to what is going wrong?

Thanks

Colin

1 Answer, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 23 May 2008, 07:15 AM
Hello Colin M,

Unfortunately currently RadChart cannot be bound to XmlDocument like this. The supported options for xml binding are described here. Still, we will forward your feedback to our developers so they can improve the behavior for one of the next versions of the control.


All the best,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Chart (Obsolete)
Asked by
Colin M
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or