The following instructions provide the code necessary to bind the FpSpread component to a data set.
The basic procedure is to bind data either to the sheet directly or to a data model that the sheet uses. This means either using the DefaultSheetDataModel class to construct a data model and then in the SheetView class set the DataModel property to the newly created data model or setting the DataSource member in the SheetView class.
|
Using Code
- Create a data model and set it equal to a DefaultSheetDataModel object, specifying a data set for the new model’s dataSource parameter.
Other parameter options are available for the DefaultSheetDataModel constructor. Refer to the Assembly Reference for complete information.
- Set the SheetView object’s DataModel property equal to the new data model.
Example
This example code binds the FpSpread component to a data set named dataSet1.
C# | Copy Code |
---|---|
// Create a data model using a data set. FarPoint.Web.Spread.Model.DefaultSheetDataModel model = new FarPoint.Web.Spread.Model.DefaultSheetDataModel(dataSet1); FpSpread1.Sheets[0].DataModel = model; |
VB | Copy Code |
---|---|
' Create a data model using a data set. Dim model As New FarPoint.Web.Spread.Model.DefaultSheetDataModel(dataSet1) FpSpread1.Sheets(0).DataModel = model |
Using a Shortcut
Set the FpSpread DataSource property.
Example
This example code uses the FpSpread DataSource property to bind to a data set.
C# | Copy Code |
---|---|
FpSpread1.DataSource = ds; |
VB | Copy Code |
---|---|
FpSpread1.DataSource = ds |