Spread for ASP.NET 9.0 Product Documentation > Developer's Guide > Managing Data Binding > Binding to a Data Source |
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.
|
Other parameter options are available for the DefaultSheetDataModel constructor. Refer to the Assembly Reference for complete information.
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 |
Set the FpSpread DataSource property.
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 |