You can bind the component to a data set. When you bind the component using the default settings, data from the data set is read into the columns and rows of the sheet to which you bind the data. Columns are associated with fields, and rows represent each record in the data set.
For the basic steps used to set up data binding, see Binding to a Data Source. For a detailed walk-through of binding to a database see, Tutorial: Binding to a Corporate Database.
You can customize data binding in many ways, including:
- You might want to specify a particular data table within a data source that has multiple tables. Use the SheetView class, DataMember property to specify the particular data member.
- You can perform more specific manipulations once the data is bound. You can use the DataField property in the Column class to bind a column to a particular data field. For instance, if you want the bound column 3 to be displayed first on the spreadsheet, or if you want to hide a column of data, or if you simply want to display the bound columns in general in a different order than they exist in the data set, you can use the DataField property in the particular column to achieve this.
- You might want to specify the key number as opposed to the row number; if so, use the DataKeyField property of the sheet.
- You can use the SQLDataAdapter instead of the OLEDB adapter when binding to a data set. To do so, use the SQLDataAdapter to set up your data set and bind it to the spreadsheet.
- In bound mode, the data model wraps the supplied data source and if needed can supply additional data and interactivity not available from the data source, for example cell formulas and unbound rows and columns. In a few cases, you may need to create your own custom data model for performance reasons. For more information about developing custom data models, refer to Using Sheet Models.
- Spread offers properties to work with model data binding in ASP.NET 4.5 and later. For more information, see Model Data Binding in ASP.NET 4.5.
There are many alternative ways to set up data binding. To learn more about data binding in Visual Studio .NET, consult the Visual Studio .NET documentation.
- How you handle state management while bound to a database or working with large data sets can affect your application’s performance. You need to set up state management to optimize performance and account for other factors. For more information, refer to Maintaining State.
- If your data set is not getting updated when you click the Update button, see the information and instructions in Limiting Postbacks When Updating Bound Data to make sure that you have code in your page load event so that you only re-create the bound data when you are loading for the first time and not overwriting it on each post back.