How to: Extend the Functionality of a Dataset
You can extend the functionality of typed datasets by writing code into the dataset's partial class file.
The code that defines typed datasets is regenerated when changes are made in the Dataset Designer or when changes are made during the running of any of the wizards that create or modify objects in the dataset; for example, the, and the TableAdapter wizards. To prevent your code from being deleted during regeneration of the dataset, add code to the dataset's partial class file. (Partial classes allow code for a specific class to be divided among multiple physical files. For more information, see or .)
To create the dataset's partial class file and add validation code, double-click columns and tables, which result in the generation ofand event handlers. For more information, see and .
To add code to a typed dataset's partial class file
Open the dataset in the Dataset Designer. For more information, see.
Double-click the design surface in an empty area to open the dataset's partial class file in the code editor.
Add your code to the dataset's partial class file.
The code in the partial class file and the generated dataset class file is compiled into one class, so variable, property, and method names, and so on must be unique across all files that define the dataset, or compiler errors will occur.