c# - DataSet and Xml

you can work with DataSet with a lot of controls, include the infragistics XamDataGrid and the DataGrid controls. 

 

DataSet has this ReadXml method to allow you to read data from Xml, so that you can use an xml as the datasource, below shows an example of how construct DataSet with Xml.

 

      public static string xmlString2 = @"<DataRowList>
    <DataRow>
         <TradeDate>Data</TradeDate>
         <TradeType>Type</TradeType>
    </DataRow>
    <DataRow>
    </DataRow>
</DataRowList>
";
      DataSet dataset = new DataSet();
      XmlReader xmlReader = XmlReader.Create(new StringReader(xmlString2));
      dataset.ReadXml(xmlReader);
      DataView dv = dataset.Tables[0].DefaultView;
      xamDatagrid.DataSource = dv;

 

As from the DataSet.ReadXml documentation, you may find there is a ReadSchema call, (while ReadXml support reading both the xml and the schema at once).  

 

More details on the DataSet schema is yet to come.

你可能感兴趣的:(C#)