Search code examples
c#asp.netlinqdata-bindingobjectdatasource

ObjectDataSource Insert failing with Business Objects


Basically an ObjectDataSource using Business Objects (Property DataObjectTypeName) using a Linq to Sql DataContext being used in a FormView.

My primary key is an integer identity, an ID.

When I set the CausesValidation property to true on the insert button it literaly does nothing. It doesn't even get to the Insert method of the data layer. However, if I set it to false, it gets to the Insert method but my business object parameter has no values in its properties.

I had a similar problem with the Update method, and it turned out that I had forgotten about the ID parameter. Specifying it as an UpdateParameter solved it. This seemed to be an issue with the Linq To SQL (correct me if I'm wrong).

But now what about the Insert method? What am I missing here? I really don't want to remove the DataObjectTypeName because the Form has like 40 fields, which would be 40 parameters to all the data methods...

Help?


Solution

  • At some point, there was a DataBind() method call on the page's Load event, and I was using my code as a custom control. Anyway... commented the call to the DataBind method, and it worked.