Editable GridView with ObjectDatasource and Update method parameters.

Recently I posted Some workaround for ObjectDataSource: could not find a non-generic method ‘…’ .
Sinse that I done some investigation to understand better the reason of the problem and possible workarounds. Most of them are posted in thread “Dataset + ObjectDatasource + GridView + ASP.NET 2” .
The problem  perfectly described here. And it is reported to MS, but they don’t want to address it.

Actually Update code trying to executeby ASP.NET  from ObjectDataSource very depends on fields and field properties, declared in GridView.
If field has ReadOnly=true or Visible=false, it is not expected as a parameter to Update method and causes the error
System.InvalidOperationException: ObjectDataSource ‘…’ could not find a nongeneric method ‘Update’ that has parameters: ….
The reason is that readonly and invisible properties are not stored in ViewState and are not available on the time of Update parameters are populated.( I beleive that MS could extract read-only fields data to submit to pass as Update parameters, but they do not in this version).
Detailed description about ObjectDataSources parameters can be found in Manuel Abadia’s blog.

So my approach is the following (in general following the tutorial “Working with Data in ASP.NET 2.0 :: An Overview of Inserting, Updating, and Deleting Data”  )  :
1.  Create the TableAdapters in the DAL (see Creating a Data Access Layer tutorial)

2.On the ASPX/ASCX page create ObjectDataSource and GridView.

3.Customize the GridView fields to specify the properties as ReadOnly,Visible=false, DataKey as required by busuness/UI requirements.

4. Run it and test inline Update method. It will return “could not find a non-generic method ‘Update’ that has parameters” error, which will list names and order of parameters that are required by gridview settings.

5. Return to strongly-typed dataset  XSD designer and add new Update adapter method with the parameters that gridView expects.
6. In ObjectDataSource change Update method to the new adaptor Update method. 

Update: I’ve posted related “Why we are getting ObjectDataSource: could not find a non-generic method ‘Update'”