You can easily perform data binding in FlexSheet. Here, we will discuss about two types of data binding: Data binding using data source and data binding using IEnumerable Interface.
To bind C1FlexSheet to a data source, we have used C1NWind.mdb database. You can find the C1NWind.mdb database in the Documents\ComponentOne Samples\Common directory.
The following code binds the C1FlexSheet control to the C1NWind.mdb database:
The above code retrieves the data from the Products table of C1NWind.mdb database. The data reflected in the FlexSheet after binding with data source is shown in the image below:
IEnumerable<T> interface inherits from the IEnumerable interface. To bind the data using IEnumerable <T> interface, a user-defined class needs to be added in the code. This class must implement the IEnumerable interface. In our case, we have created a class named Customer to implement the IEnumerable interface.
The following code implements the IEnumerable interface:
The above code retrieves the data from a list of customers and their details defined in Customers class. The data reflected in the FlexSheet after binding with IEnumerable<T> interface is shown in the image below: