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

Binding dynamic XML to the GridView

13 Answers 326 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FieldTRAKS
Top achievements
Rank 1
FieldTRAKS asked on 08 Jul 2009, 08:47 PM
Our system provides a mechanism by which our users define their business rules outside of our code. Our front end applications adapt to these business rules by dynamically assembling all data entry dialogs at runtime. Since there are n-possible properties for a given dialog we need a way to bind the XML that we retrieve through are webservice without defining a class that can be use as an IList for the datasource.

Basically we can probe the webservice for the column names and datatypes that a the dataview should display but we cannot define a matching object in code since the activities and properties that can be defined are customized in our database.

Another way to look at this is to tell me how to bind the following XML(See below) to a GridView without the benefit of having an object that has the same column values. In the example below the <evt_mast_chemical> tag delineates a row and the child tags are the column values. Keep in mind that a new activity could be defined 5 minutes from now that would have a completely different column values. I do have schema information that delineates what each column value datatype is.


<?xml version="1.0" encoding="utf-8"?>
<DocumentElement>
  <evt_mast_chemical>
    <id>23168</id>
    <eventtypeid>20</eventtypeid>
    <userid>27</userid>
    <parentid>27</parentid>
    <objectid>84</objectid>
    <objecttable>field</objecttable>
    <datetime>2007-04-17T10:42:21-04:00</datetime>
    <sparentid>0</sparentid>
    <Farm_id>3</Farm_id>
    <Farm>Branson Farms</Farm>
    <Field_id>84</Field_id>
    <Field>Field 5 of 10</Field>
    <Active_x0020_Ingredient>N/R</Active_x0020_Ingredient>
    <Air_x0020_Temperature />
    <Air_x0020_Temperature_x0020_unit>C</Air_x0020_Temperature_x0020_unit>
    <Applicator_x0020_Certification_x0020_Number>fddssd</Applicator_x0020_Certification_x0020_Number>
    <Barcode />
    <Chem_x0020_EPA_x0020_Reg>Exempt</Chem_x0020_EPA_x0020_Reg>
    <Chem_x0020_Manufacturer>Helena</Chem_x0020_Manufacturer>
    <Chem_x0020_Product>Joint Venture</Chem_x0020_Product>
    <Chem_x0020_Type>Adjuvant</Chem_x0020_Type>
    <Chemical_x0020_Application_x0020_Method>Drops</Chemical_x0020_Application_x0020_Method>
    <Chemical_x0020_Application_x0020_Rate />
    <Chemical_x0020_Application_x0020_Rate_x0020_unit>dry oz / acre</Chemical_x0020_Application_x0020_Rate_x0020_unit>
    <Chemical_x0020_Applicator_x0020_Comments />
    <Chemical_x0020_Applied_x0020_Area />
    <Chemical_x0020_Applied_x0020_Area_x0020_unit>acres</Chemical_x0020_Applied_x0020_Area_x0020_unit>
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029_ />
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>$</Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>
    <Crop_x0020_for_x0020_Chem_x0020_App>Soybeans</Crop_x0020_for_x0020_Chem_x0020_App>
    <Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>2007-04-19T10:30:07-04:00</Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>
    <Duration_x0020_Until_x0020_Re-Entry />
    <Duration_x0020_Until_x0020_Re-Entry_x0020_unit>days</Duration_x0020_Until_x0020_Re-Entry_x0020_unit>
    <Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical>dafgd</Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical>
    <Humidity_x0020__x0028__x0025__x0029_ />
    <Name_x0020_of_x0020_Chemical_x0020_Applicator>adl;jf;lak</Name_x0020_of_x0020_Chemical_x0020_Applicator>
    <Residue_x0020_Cover_x0020__x0028__x0025__x0029_ />
    <Soil_x0020_Condition />
    <Weather_x0020_Conditions />
    <Wind_x0020_Direction />
    <Wind_x0020_Speed />
  </evt_mast_chemical>
  <evt_mast_chemical>
    <id>31979</id>
    <eventtypeid>20</eventtypeid>
    <userid>27</userid>
    <parentid>27</parentid>
    <objectid>84</objectid>
    <objecttable>field</objecttable>
    <datetime>2007-06-08T09:34:16-04:00</datetime>
    <sparentid>0</sparentid>
    <Farm_id>3</Farm_id>
    <Farm>Branson Farms</Farm>
    <Field_id>84</Field_id>
    <Field>Field 5 of 10</Field>
    <Active_x0020_Ingredient>PCNB</Active_x0020_Ingredient>
    <Air_x0020_Temperature />
    <Air_x0020_Temperature_x0020_unit>C</Air_x0020_Temperature_x0020_unit>
    <Applicator_x0020_Certification_x0020_Number />
    <Barcode />
    <Chem_x0020_EPA_x0020_Reg>400-453</Chem_x0020_EPA_x0020_Reg>
    <Chem_x0020_Manufacturer>Crompton</Chem_x0020_Manufacturer>
    <Chem_x0020_Product>Terraclor</Chem_x0020_Product>
    <Chem_x0020_Type>Fungicide</Chem_x0020_Type>
    <Chemical_x0020_Application_x0020_Method />
    <Chemical_x0020_Application_x0020_Rate>56</Chemical_x0020_Application_x0020_Rate>
    <Chemical_x0020_Application_x0020_Rate_x0020_unit>dry oz / acre</Chemical_x0020_Application_x0020_Rate_x0020_unit>
    <Chemical_x0020_Applicator_x0020_Comments />
    <Chemical_x0020_Applied_x0020_Area>0</Chemical_x0020_Applied_x0020_Area>
    <Chemical_x0020_Applied_x0020_Area_x0020_unit>acres</Chemical_x0020_Applied_x0020_Area_x0020_unit>
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029_ />
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>$</Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>
    <Crop_x0020_for_x0020_Chem_x0020_App>Soybeans</Crop_x0020_for_x0020_Chem_x0020_App>
    <Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>2007-06-13T00:00:00-04:00</Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>
    <Duration_x0020_Until_x0020_Re-Entry />
    <Duration_x0020_Until_x0020_Re-Entry_x0020_unit>days</Duration_x0020_Until_x0020_Re-Entry_x0020_unit>
    <Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical />
    <Humidity_x0020__x0028__x0025__x0029_ />
    <Name_x0020_of_x0020_Chemical_x0020_Applicator />
    <Residue_x0020_Cover_x0020__x0028__x0025__x0029_ />
    <Soil_x0020_Condition />
    <Weather_x0020_Conditions />
    <Wind_x0020_Direction />
    <Wind_x0020_Speed />
  </evt_mast_chemical>
  <evt_mast_chemical>
    <id>93640</id>
    <eventtypeid>20</eventtypeid>
    <userid>27</userid>
    <parentid>27</parentid>
    <objectid>84</objectid>
    <objecttable>field</objecttable>
    <datetime>2009-06-19T11:34:44-04:00</datetime>
    <sparentid>0</sparentid>
    <Farm_id>3</Farm_id>
    <Farm>Branson Farms</Farm>
    <Field_id>84</Field_id>
    <Field>Field 5 of 10</Field>
    <Active_x0020_Ingredient />
    <Air_x0020_Temperature>0</Air_x0020_Temperature>
    <Air_x0020_Temperature_x0020_unit>C</Air_x0020_Temperature_x0020_unit>
    <Applicator_x0020_Certification_x0020_Number />
    <Barcode>0</Barcode>
    <Chem_x0020_EPA_x0020_Reg />
    <Chem_x0020_Manufacturer />
    <Chem_x0020_Product />
    <Chem_x0020_Type />
    <Chemical_x0020_Application_x0020_Method>Banding</Chemical_x0020_Application_x0020_Method>
    <Chemical_x0020_Application_x0020_Rate>0</Chemical_x0020_Application_x0020_Rate>
    <Chemical_x0020_Application_x0020_Rate_x0020_unit>dry oz / acre</Chemical_x0020_Application_x0020_Rate_x0020_unit>
    <Chemical_x0020_Applicator_x0020_Comments />
    <Chemical_x0020_Applied_x0020_Area>0</Chemical_x0020_Applied_x0020_Area>
    <Chemical_x0020_Applied_x0020_Area_x0020_unit>acres</Chemical_x0020_Applied_x0020_Area_x0020_unit>
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029_>0</Chemical_x0020_Cost_x0020__x0028_Est._x0029_>
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>$</Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>
    <Crop_x0020_for_x0020_Chem_x0020_App />
    <Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>2009-06-19T11:34:41-04:00</Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>
    <Duration_x0020_Until_x0020_Re-Entry>0</Duration_x0020_Until_x0020_Re-Entry>
    <Duration_x0020_Until_x0020_Re-Entry_x0020_unit>days</Duration_x0020_Until_x0020_Re-Entry_x0020_unit>
    <Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical />
    <Humidity_x0020__x0028__x0025__x0029_>0</Humidity_x0020__x0028__x0025__x0029_>
    <Name_x0020_of_x0020_Chemical_x0020_Applicator>hhh</Name_x0020_of_x0020_Chemical_x0020_Applicator>
    <Residue_x0020_Cover_x0020__x0028__x0025__x0029_>0</Residue_x0020_Cover_x0020__x0028__x0025__x0029_>
    <Soil_x0020_Condition />
    <Weather_x0020_Conditions />
    <Wind_x0020_Direction />
    <Wind_x0020_Speed />
  </evt_mast_chemical>
</DocumentElement>

13 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Jul 2009, 05:26 AM
Hi Dave,

You can easily use my DataTable class to define any type of columns dynamically and the grid will work as expected.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
FieldTRAKS
Top achievements
Rank 1
answered on 14 Jul 2009, 03:35 AM
I added this to your datatable solution and it does not work. IT either crashes ie or the grid displays momentarily then the page goes blank

<UserControl x:Class="SilverlightDataTable.pgReport"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadGridView x:Name="datagrid"/>
    </Grid>
</UserControl>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Data;
using System.Xml.Linq;


namespace SilverlightDataTable
{
    public partial class pgReport : UserControl
    {

        string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<NewDataSet>
  <xs:schema id=""NewDataSet"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"">
    <xs:element name=""NewDataSet"" msdata:IsDataSet=""true"" msdata:MainDataTable=""evt_mast_chemical"" msdata:UseCurrentLocale=""true"">
      <xs:complexType>
        <xs:choice minOccurs=""0"" maxOccurs=""unbounded"">
          <xs:element name=""evt_mast_chemical"" msdata:Eventtypeid=""20"" msdata:Agtype="""" msdata:Eventname=""evt_mast_chemical"" msdata:Eventalias=""Record a Chemical Application"">
            <xs:complexType>
              <xs:sequence>
                <xs:element name=""id"" type=""xs:int"" minOccurs=""0"" />

                <xs:element name=""eventtypeid"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""userid"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""parentid"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""objectid"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""objecttable"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""datetime"" type=""xs:dateTime"" minOccurs=""0"" />
                <xs:element name=""sparentid"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""Farm_id"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""Farm"" type=""xs:string"" minOccurs=""0"" />

                <xs:element name=""Field_id"" type=""xs:int"" minOccurs=""0"" />
                <xs:element name=""Field"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Active_x0020_Ingredient"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""353"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Air_x0020_Temperature"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""True"" msdata:IsUnit=""False"" msdata:Unittypeid=""13"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""81"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Air_x0020_Temperature_x0020_unit"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""True"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""81 unit"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Applicator_x0020_Certification_x0020_Number"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""158"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Barcode"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""80"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chem_x0020_EPA_x0020_Reg"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""352"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chem_x0020_Manufacturer"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""351"" type=""xs:string"" minOccurs=""0"" />

                <xs:element name=""Chem_x0020_Product"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""350"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chem_x0020_Type"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""349"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Application_x0020_Method"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""159"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Application_x0020_Rate"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""True"" msdata:IsUnit=""False"" msdata:Unittypeid=""5"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""77"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Application_x0020_Rate_x0020_unit"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""True"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""77 unit"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Applicator_x0020_Comments"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""88"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Applied_x0020_Area"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""True"" msdata:IsUnit=""False"" msdata:Unittypeid=""1"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""78"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Applied_x0020_Area_x0020_unit"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""True"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""78 unit"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Cost_x0020__x0028_Est._x0029_"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""True"" msdata:IsUnit=""False"" msdata:Unittypeid=""8"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""157"" type=""xs:string"" minOccurs=""0"" />

                <xs:element name=""Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""True"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""157 unit"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Chemical_x0020_Expiration"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""229"" type=""xs:dateTime"" minOccurs=""0"" />
                <xs:element name=""Crop_x0020_for_x0020_Chem_x0020_App"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""348"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""79"" type=""xs:dateTime"" minOccurs=""0"" />
                <xs:element name=""Duration_x0020_Until_x0020_Re-Entry"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""True"" msdata:IsUnit=""False"" msdata:Unittypeid=""12"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""228"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Duration_x0020_Until_x0020_Re-Entry_x0020_unit"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""True"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""228 unit"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""86"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Humidity_x0020__x0028__x0025__x0029_"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""82"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Name_x0020_of_x0020_Chemical_x0020_Applicator"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""85"" type=""xs:string"" minOccurs=""0"" />

                <xs:element name=""Residue_x0020_Cover_x0020__x0028__x0025__x0029_"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""84"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Soil_x0020_Condition"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""75"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Weather_x0020_Conditions"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""72"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Wind_x0020_Direction"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""73"" type=""xs:string"" minOccurs=""0"" />
                <xs:element name=""Wind_x0020_Speed"" msdata:PointsToGeometry=""False"" msdata:IsGeometry=""False"" msdata:HasUnit=""False"" msdata:IsUnit=""False"" msdata:Unittypeid=""0"" msdata:IsResolvedObjList=""False"" msdata:IsObjList=""False"" msdata:IsMultiObj=""False"" msdata:Owner="""" msdata:Caption=""74"" type=""xs:string"" minOccurs=""0"" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>

      </xs:complexType>
    </xs:element>
  </xs:schema>
  <evt_mast_chemical>
    <id>1</id>
    <eventtypeid>20</eventtypeid>
    <userid>27</userid>

    <parentid>27</parentid>
    <objectid>84</objectid>
    <objecttable>field</objecttable>
    <datetime>2009-07-11T08:55:13-04:00</datetime>
    <sparentid>0</sparentid>
    <Farm_id>3</Farm_id>

    <Farm>Branson Farms</Farm>
    <Field_id>84</Field_id>
    <Field>Field 5 of 10</Field>
    <Active_x0020_Ingredient>Mono- and di- potassium salts of phosphorous acid</Active_x0020_Ingredient>
    <Air_x0020_Temperature>0</Air_x0020_Temperature>
    <Air_x0020_Temperature_x0020_unit>C</Air_x0020_Temperature_x0020_unit>

    <Applicator_x0020_Certification_x0020_Number />
    <Barcode>0</Barcode>
    <Chem_x0020_EPA_x0020_Reg>68573-2</Chem_x0020_EPA_x0020_Reg>
    <Chem_x0020_Manufacturer>JH Biotech</Chem_x0020_Manufacturer>
    <Chem_x0020_Product>Fosphite</Chem_x0020_Product>
    <Chem_x0020_Type>Fungicide</Chem_x0020_Type>

    <Chemical_x0020_Application_x0020_Method>In Furrow</Chemical_x0020_Application_x0020_Method>
    <Chemical_x0020_Application_x0020_Rate>0</Chemical_x0020_Application_x0020_Rate>
    <Chemical_x0020_Application_x0020_Rate_x0020_unit>dry oz / acre</Chemical_x0020_Application_x0020_Rate_x0020_unit>
    <Chemical_x0020_Applicator_x0020_Comments />
    <Chemical_x0020_Applied_x0020_Area>0</Chemical_x0020_Applied_x0020_Area>
    <Chemical_x0020_Applied_x0020_Area_x0020_unit>acres</Chemical_x0020_Applied_x0020_Area_x0020_unit>

    <Chemical_x0020_Cost_x0020__x0028_Est._x0029_>0</Chemical_x0020_Cost_x0020__x0028_Est._x0029_>
    <Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>$</Chemical_x0020_Cost_x0020__x0028_Est._x0029__x0020_unit>
    <Crop_x0020_for_x0020_Chem_x0020_App>Beets</Crop_x0020_for_x0020_Chem_x0020_App>
    <Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>2009-07-11T08:55:00-04:00</Date_x002F_Time_x0020_of_x0020_Chemical_x0020_Application>
    <Duration_x0020_Until_x0020_Re-Entry>0</Duration_x0020_Until_x0020_Re-Entry>
    <Duration_x0020_Until_x0020_Re-Entry_x0020_unit>days</Duration_x0020_Until_x0020_Re-Entry_x0020_unit>

    <Equipment_x0020_Used_x0020_to_x0020_Apply_x0020_Chemical />
    <Humidity_x0020__x0028__x0025__x0029_>0</Humidity_x0020__x0028__x0025__x0029_>
    <Name_x0020_of_x0020_Chemical_x0020_Applicator>sss</Name_x0020_of_x0020_Chemical_x0020_Applicator>
    <Residue_x0020_Cover_x0020__x0028__x0025__x0029_>0</Residue_x0020_Cover_x0020__x0028__x0025__x0029_>
    <Soil_x0020_Condition />
    <Weather_x0020_Conditions />
    <Wind_x0020_Direction />

    <Wind_x0020_Speed />
  </evt_mast_chemical>
</NewDataSet>";
        Telerik.Data.DataTable table =
            new Telerik.Data.DataTable();
        XDocument report;

        public XDocument Report
        {
            get { return report; }
            set { report = value;
            BindData();
            }
        }

        private void BindData()
        {
            schemans = ((XElement)report.Root.FirstNode).GetNamespaceOfPrefix("xs").NamespaceName;
            schemams = ((XElement)report.Root.FirstNode).GetNamespaceOfPrefix("msdata").NamespaceName;
            var query = from c in report.Descendants(XName.Get("element", schemans)).ToList()
                        where c.Parent.Name.LocalName == "sequence"
                        select c;

            schemanodes = query.ToList<XElement>();

            CreateColumns();
           
            datagrid.ItemsSource = table;
        }
        string schemans, schemams;

        List<XElement> schemanodes = new List<XElement>();
        public pgReport()
        {
            InitializeComponent();
            Report = XDocument.Parse(xml);
            
        }

        private void CreateColumns()
        {
            List<XElement> xel = schemanodes.Where(c => c.Attribute(XName.Get("IsGeometry", schemams)) != null).ToList();
            foreach (XElement xe in xel)
            {
                string name = FTSilverControls.Utility.XMLNameResolver(xe.Attribute(XName.Get("name")).Value, false).Replace(" ","_");
               DataColumn dc = new DataColumn() { ColumnName = name, DataType = typeof(string) };
                table.Columns.Add(dc);

            }
                Telerik.Data.DataRow dr = new Telerik.Data.DataRow();
            for(int i =0; i <table.Columns.Count ; i++)
            {
                dr[table.Columns[i].ColumnName] = i.ToString();
            }

           table.Rows.Add(dr);
        
        }
    }
}
0
Vlad
Telerik team
answered on 14 Jul 2009, 05:39 AM
Hello Dave,

Usually page goes blank when you have exception - can you post more info about this error? Stack trace will be fine!

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
FieldTRAKS
Top achievements
Rank 1
answered on 14 Jul 2009, 12:33 PM
Microsoft JScript runtime error: Unhandled Error in Silverlight 2 Application Operation is not valid due to the current state of the object.   at System.Windows.DependencyObject.get_NativeObject()
   at System.Windows.DependencyObject.MS.Internal.INativeCoreTypeWrapper.GetNativePeer()
   at MS.Internal.XcpImports.GetValue(INativeCoreTypeWrapper obj, DependencyProperty property)
   at System.Windows.DependencyObject.GetValueInternal(DependencyProperty dp)
   at System.Windows.FrameworkElement.GetValueInternal(DependencyProperty dp)
   at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
   at System.Windows.FrameworkElement.get_ActualWidth()
   at System.Windows.Controls.Primitives.ScrollBar.GetTrackLength()
   at System.Windows.Controls.Primitives.ScrollBar.OnViewportSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValue(DependencyProperty property, Double d)
   at System.Windows.Controls.Primitives.ScrollBar.set_ViewportSize(Double value)
   at Telerik.Windows.Controls.GridView.ScrollBarStateController.UpdateScrollBar(ScrollBar scrollBar, ScrollBarProperties properties)
   at Telerik.Windows.Controls.GridView.ScrollBarStateController.UpdateHorizontalScrollBarsProperties(ScrollBarProperties properties)
   at Telerik.Windows.Controls.GridView.GridViewScrollViewer.UpdateScrollBars()
0
FieldTRAKS
Top achievements
Rank 1
answered on 14 Jul 2009, 12:42 PM
I think I found the problem...I forced the code to only process the first 6 columns and it work...So it has something to do with the number of columns I think. I can work around for now for my demo but in our final product this will have to work
0
FieldTRAKS
Top achievements
Rank 1
answered on 14 Jul 2009, 04:04 PM
I also found a further problem...your control does not like the column names to have spaces in them
0
FieldTRAKS
Top achievements
Rank 1
answered on 14 Jul 2009, 04:19 PM
Upon further investigation your control does not like most special characters....Do you plan to address this?
0
Vlad
Telerik team
answered on 15 Jul 2009, 06:01 AM
Hi Dave,

I believe that my DataTable does not support columns with space since there is no properties with space as to the grid I've just tried this code and everything worked fine:

XAML
<UserControl x:Class="SilverlightApplication2.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:gridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    <Grid x:Name="LayoutRoot" Background="White"
        <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn UniqueName="Customer ID" DataMemberBinding="{Binding CustomerID}"/> 
                <telerik:GridViewDataColumn UniqueName="Company Name" DataMemberBinding="{Binding CompanyName}"/> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 
</UserControl> 
 


C#
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using System.Windows.Data; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Controls.GridView; 
using System.ComponentModel; 
using System.Threading; 
using Telerik.Windows.Data; 
using System.Windows.Browser; 
using System.Windows.Controls.Primitives; 
 
namespace SilverlightApplication2 
    public partial class Page : UserControl 
    { 
        public Page() 
        { 
            InitializeComponent(); 
 
            RadGridView1.ItemsSource = from i in Enumerable.Range(0, 30) 
                                       select new Customer() 
                                       { 
                                           CustomerID = i, 
                                           CompanyName = String.Format("CompanyName{0}", i) 
                                       }; 
        } 
    } 
 
    public class Customer 
    { 
        public int CustomerID { getset; } 
        public string CompanyName { getset; } 
    } 
 


Can you post more info about special characters problem?

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Harish
Top achievements
Rank 1
answered on 26 Oct 2010, 12:18 AM
Hi Vlad,

I have been using your DataTable to bind the data from a stored proc/table. I am facing a similar issue with column names with special characters as mentioned above. Ex if I have a query like

Select EmpId, Emp_Name, Reportees as 'Reportees #', Profit as 'Profit %' from Emp

the column headers appear as per the aliases as in the query however the data associated with the column is displayed as blank. I tried this even with a regular silverlight grid and experienced similar output. Any help regarding this?

Hari

0
Vlad
Telerik team
answered on 26 Oct 2010, 07:28 AM
Hi Harish,

 Unfortunately creating properties with such names from these column names can cause problems. 

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adrian Pay
Top achievements
Rank 1
answered on 27 Oct 2011, 03:55 AM
this link is dead. can u repost. thanks!

http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx
0
Vlad
Telerik team
answered on 27 Oct 2011, 07:24 AM
Hi,

 I strongly suggest you to check this blog post first:
http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
SchaF
Top achievements
Rank 1
answered on 07 Feb 2012, 09:05 PM
So as of right now any columns that contain a /\ or other illegal XML characters cannot work correctly to display data in the gridview.
Tags
GridView
Asked by
FieldTRAKS
Top achievements
Rank 1
Answers by
Vlad
Telerik team
FieldTRAKS
Top achievements
Rank 1
Harish
Top achievements
Rank 1
Adrian Pay
Top achievements
Rank 1
SchaF
Top achievements
Rank 1
Share this question
or