Tips, Tricks, and Fixes for when your computer doesn't do what it's told.

Monday, December 22, 2008

Insert Error Using ObjectDatasource and TableAdapter

Using an ObjectDataSource bound to a FormView, when calling the Insert method, the error "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'methodname' that has parameters:...etc" This error is caused because TableAdapter is tacking the ID field to the end of the calling parameters even though it is not specified in the tags.

To avoid this problem, the ID field must be bound on the page and editable.

Or the ID field should not be on the page at all. In my particular case, this was the problem, since I did not want my users to edit the primary key of course, but I wanted it visible in a label field. Removing the label field, made the error go away.

More observations on this error can be found at http://weblogs.asp.net/bradygaster/archive/2006/09/26/How-to-Bloody-Your-Forehead.aspx

No comments: