ObjectDataSource Object Exception

I am working on an ASP.NET page with a GridView and an ObjectDataSource .

I want to configure an ObjectDataSource object to a class (decorated with DataObject ()) at my business level. The class, among many others, is set up in a very similar way. I selected the class and clicked Next to select the function for SelectMethod, but it closes without warning and without any errors.

I can set the TypeName for the ObjectDataSource and attach it to the GridView . I tried Refresh Schema and I got an error:

An error occurred while calling "Update Schema". Details: An exception was thrown by the call target.

I can manually configure ObjectDataSource , but I'm essentially lazy and prefer to use a graphical interface.

Why doesn't it work?

Everything builds perfectly. I can manually connect everything and the page is working fine. However, it still fails when I go to configure the ObjectDataSource with the user interface.

+4
source share
1 answer

The ODS control has some prerequisites for proper operation and will generate this general Exception has been thrown by the target of an invocation. if some of these configurations are incorrect. Here are a few things to try to fix the problem:

  • The class associated with the ODS control must have an empty default constructor that accepts no parameters. This is fine to overload it, but there should be a default empty constructor; make sure it exists.

  • ODS may fail in a linked class if that class exists in another project referenced by your user interface project that contains ODS. Make sure you completely clean and rebuild the solution so that the current class diagram can be read by Wizzard ODS.

  • Try to remove ODS (save all configured properties from IDS in the source to notepad to add them later to the item) and add a new one. After adding a new ODS, use Wizzard to point to the class you want and see if it works.

0
source

All Articles