HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Sunday, July 22, 2012

How to: Bind a Control to Data in an XML File

This example demonstrates a way of binding a data-aware control (XtraGrid, XtraPivotGrid, XtraVerticalGrid, etc.) to data stored in an XML file. Note that specific controls may need additional customization after the control is bound to a data source. For more information refer to documentation of the corresponding control.

The code sample below binds a GridControl to XML data stored in an XML file.

C#:

// Create a DataSet and fill it with data from an XML file. 

DataSet xmlDataSet = new DataSet();

xmlDataSet.ReadXml("e:\\DBs\\Cars.xml");

 

// Bind the grid to the DataSet. 

gridControl1.DataSource = xmlDataSet.Tables[0];

 

VB

' Create a DataSet and fill it with data from an XML file. 
Dim XMLDataSet As New DataSet()
XMLDataSet.ReadXml("e:\DBs\Cars.xml")
 
' Bind the grid to the DataSet. 
GridControl1.DataSource = XMLDataSet.Tables(0)

 

No comments:

Post a Comment