5 out of 8 rated this helpful - Rate this topic

How to: Extend the Functionality of a TableAdapter 

You can extend the functionality of a TableAdapter by adding code to the TableAdapter's partial class file.

The code that defines a TableAdapter is regenerated when any changes are made to the TableAdapter (in the Dataset Designer) or when changes are made during the running of any wizard that modifies the configuration of a TableAdapter. To prevent your code from being deleted during the regeneration of a TableAdapter, add code to the TableAdapter's partial class file.

(Partial classes allow code for a specific class to be divided among multiple physical files. For more information, see Partial (Visual Basic) or partial (C# Reference).)

Locating TableAdapters in Code

While TableAdapters are designed with the Dataset Designer, the TableAdapter classes generated are not generated as nested classes of the DataSet. TableAdapters are located in a namespace based on the name of the TableAdapter's associated dataset. For example, if your application contains a dataset named HRDataSet, the TableAdapters would be located in the HRDataSetTableAdapters namespace. (The naming convention follows this pattern: DatasetName + TableAdapters).

The following example assumes a TableAdapter named CustomersTableAdapter in a project with a NorthwindDataSet.

To create a partial class for a TableAdapter

  1. Add a new class to your project by choosing Add Class from the Project menu.

  2. Name the class CustomersTableAdapterExtended.

  3. Click Add.

  4. Replace the code with the proper namespace and partial class name for your project. For example:

    namespace NorthwindDataSetTableAdapters
    {
        public partial class CustomersTableAdapter
        {
            // Add user code here. For example:
            public override string ToString()
            {
                return "Overridden in the partial class.";
            }
        }
    }
    
    

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Adding Event Handlers?
In C#, where would I add an Event Handler to the TableAdapter.  Like the previous poster, I too am trying to trap the RowUpdated events.

If this is not something possible to do in C# (though it clearly is something you can do in VB.Net), then I would chalk this up as a bug that Microsoft needs to fix.
Exposing Rowupdate/Rowupdating
What about exposing RowUpdate or RowUpdating events? 
How to do that?
If presentation layer is not an option to add Event Handler where you can add Event Handler for these in C#? In business layer or data layer or somewhere else.?