Here's the scenario:

  1. You use the great new DataSet designer in VS 2005 and have it generate some tableadapters for you.
  2. You want to inherit from them to add some application (business) logic and some new methods
  3. Works great, the tableadapters are not sealed and the methods you want are all virtual
  4. But when you try to bind then using the ObjectDataSource on a web page, the nice new methods you've created are not listed!

    This seems to be an issue with the ObjectDataSource UI because if you put them in manually in the HTML source then it works fine.  However a neater solution is to use the following attribute on your methods so that they become visible to the ObjectDataSource UI:

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
    public int MySelectMethod(){}

    There are five enumerations for DataObjectMethodType: Delete, Fill, Select, Insert, Update covering all eventualities
  5. Go home with the warm feeling of a job well done ;-)

HTH

Ian

Comments are disabled for this blog - but please feel free to comment via the contact page