Monday, October 27, 2008

ObjectDataSource 'myObjDataDource' could not find a non-generic method 'myMethod' that has parameters: my_ID

Most programmers working with asp.net ObjectDataSource are bound to be irritated by this error: ObjectDataSource 'myObjDataDource' could not find a non-generic method 'myMethod' that has parameters: my_ID


 

I guess this is due to the nature the asp.net ObjectDataSource does so many things automatically. As I have described in this article that well describes how to do master detail data display using asp.net GridView and DetailsView controls by use of asp.net ObjectDataSource, we can use business objects to perform various database operations using asp.net ObjectDataSource control. All we have to do is define the correspomding methods in the business logic layer (BLL), which can be done easily using either three tier or two tier asp.net web application architecture, either involving only . business logic layer (BLL) or using both business logic layer (BLL) and Data Access Layer (DLL). So there are some points that will help detect why the "objectdatasource could not find the non-generic method" error occurs.

  1. Make sure all methods [SelectMethod, UpdateMethod, DeleteMethod, SelectCountMethod, InsertMethod] used by the ObjectDataSource are typed correctly.
  2. Check to verify the Type actually contains the above methods (mostly programmers may have misspelled them).
  3. Third but important point: do these methods contain exact parameters as pointed in the error, both in number and order. Remember that the order of parameters mean a lot for ObjectDataSource methods. (And perhaps you too are stumbled here! At least I had this problem.)

Follow the above steps and you are nearest to the solution. At least my experience tells these careful steps will guide you understand the core of asp.net objectdatasource control's behavious. Please share if you have similar or advanced experiences regarding this "objectdatasource could not find the non-generic method" error.

Happy programming!

2 comments:

Anonymous said...

Thanks. your post is very helpful.

Anonymous said...

Also set OldValuesParameterFormatString to "{0}" if you are not using optimistic concurrency..

that was 45 mins of my life never to return ;)

Post a Comment

Hope you liked this post. You can leave your message or you can put your valuable suggestions on this post here. Thanks for the sharing and cooperation!

Popular Posts

Recent Articles