XmlDocument DataBind

Thread is closed for posting
2 posts, 1 answers
  1. Colin M
    Colin M avatar
    1 posts
    Member since:
    Jul 2012

    Posted 22 May 2008 Link to this post

    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
  2. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 May 2008 Link to this post

    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
Back to Top