DevExpress XtraGrid DATA BINDING METHODS

 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.


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:.111

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值