Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

I've hit the same problem again. I've already wrote 2 posts  about the error "Exception Details: System.InvalidOperationException: ObjectDataSource 'ods' could not find a non-generic method 'Update' that has parameters:...." ( Editable GridView with ObjectDatasource and Update method parameters. and Some workaround for ObjectDataSource: could not find a non-generic method '...'.) And these posts are the most popular in my blog according to views statistics. Not because they are very useful - just because topic is very hot - a lot of people experience the same problem.

I've read again and understood, that his sample very similar to mine. I also have table with integer IDENTITY primary key and 2 nvarchar columns. Ive used DataAdapter wizard to generate insert/update/delete methods without generating Stored Procedures and without support for optimistic cuncurrency. And I am using DetailsView instead of editable GridView.

I believe that the root of the problem is in the wrong assumption which parameters should have default Update method. Just follow Brady's example the function is Update(String Firstname, String Lastname, int32 Original_PersonId, int32 PersonId)  

How often developer needs to update IDENTITY PRIMARY KEY? If not, why we need the last parameter? If the generated Update will have just 3 parameters(Firstname, Lastname,  Original_PersonId),GridView and DetailView will work as expected.

I've  raised suggestion to MS "Generated default Update method in DataTableAdapter in a typed DataSet  shouuld not update primary key". Please rate/validate it.

UPDATE: Hurray! Posted by Microsoft on 5/05/2007: "We have fixed the issue with an additional update function. The fix will be available in the next VS release."

This article is part of the GWB Archives. Original Author: Michael Freidgeim

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.