Dirk Bergmann

Developer, panographer. Does consultancy work from own company. Lives in Chiang Mai, Thailand.

Twitter

Chiang Mai

Hua Hin

Thailand Hotels

ListVote - List. Vote. Learn.

Partnerseek - Find Partners

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters:...

When building an editable ASP.NET 2.0 GridView or **DetailsView **this error is probably the most common issue. There must hardly be a developer who has not come across it at one time or another. It occurs when working with an ObjectDataSource based on a TableAdapter in ASP.NET 2.0, the easy path to enable Updating, Inserting and Deleting without any code or stored procedures the TableAdapter respresenting the data layer. This is the main advantage the GridView has over the DataGrid of .NET v.1x yore.

There is plenty of discussion of this issue available online, but two measure are mandatory:

First, always set the** ReadOnly** property of the data key fields of your GridView or DetailsView to** False**. It' True by default. It's very easy to forget to redo this when rebinding the GridView.

![](/px/16e05ec1a9b0_1463D/image0_thumb3.png)

 

Second, when configuring the TableAdapter with th TableAdapter Configuration Wizard, be sure to not use a wildcard in the query at "What data should be loaded into the table?", so use

{:tag :br, :attrs nil, :content []}SELECT FirstName, LastName, ID FROM Customer;

instead of

{:tag :br, :attrs nil, :content []}SELECT * FROM Customer

A click on the Query Builder... button will reformat the query automatically.

![](/px/16e05ec1a9b0_1463D/image0_thumb12.png)

Some say that disabling the second or third of the Advanced Options helps with this issue, however, I cannot confirm that is has any real effect.

![](/px/16e05ec1a9b0_1463D/image0_thumb9.png)

Always remember to do and redo these two things and your GridView will manage your data just fine.