1 Two Important Proptery
This property is used when the DataSource property refers to a dataset containing several data tables. The DataMember property should specify the desired table's name in this case. The specified table's data is supplied for the grid control's main view.
If the DataSource property refers to a data table, data view or any custom created data source object, the DataMember property should not be used.
2 DATA BINDING METHODS
To bind a grid control to a data source, you will need to use its GridControl.DataSource property. Note that this doesn't depend on the data binding method that you choose. Additionally, you may need to use the GridControl.DataMember property. This is necessary if the specified data source is a dataset containing several tables. In this case, the GridControl.DataMember property identifies which of the available tables must be bound to the grid. In other cases, this property value is ignored.
Data binding methods differ in how to obtain an object assigned to the GridControl.DataSource property. This depends on the type of data to which the grid must be bound. You can bind the grid to data from a database, from an XML file or to any data created at runtime. Thus, three data binding methods are available:
- Using .NET Data Providers
This method implies that data is stored in a database. You can bind your grid control to such data using one of the two data adapter components supplied: OleDBDataAdapter and SqlDataAdapter. The first accesses data sources exposed using OLE DB. The second is designed to work with data sources provided by Microsoft SQL Server version 7.0 or later. Both data adapters use connection objects to bind to data and are capable of generating DataSet objects that contain data tables. Data tables (or data views bound to tables) can be bound to the grid by assigning them directly to the GridControl.DataSource property. You can also assign the DataSet object generated to the GridControl.DataSource property and specify the table name using the GridControl.DataMember property.
- Binding to XML Data
This method uses data stored in an XML file. To access such data, you need to create a DataSet object and use its ReadXML method. This results in the creation of appropriate tables within the DataSet. Once tables are created, they can be bound to the grid control. Again, this can be done by a direct assignment to the GridControl.DataSource property or by using the GridControl.DataSource and GridControl.DataMember properties in combination.
- Binding to Data Created at Runtime
The data object created is assigned to the GridControl.DataSource property. This object must support the IList, ITypedList or IBindingList interface.
Note that you don't have to create custom data source objects. You can use a DataTable object filled with data at runtime, if it suits your needs.
The image below illustrates all the data binding methods mentioned:.