Access ReturnValue in the Inserted event of an ObjectDataSource.

Apr 9, 2008 at 3:24 PM
Hi there!

I am using a DetailsView + ObjectDataSource to insert a new row to database using the generated 'Insert' function.
In the 'Inserted' event of the ObjectDataSource I want to check if my data was saved to db or not using the ReturnValue property of the ObjectDataSourceStatusEventArgs.
But this value is always null because the generated Insert method returns void instead of int as the Execute method does.

If I change the Insert function in the generated code so it returns int instead of void I can access it's result in the ReturnValue property in the 'Inserted' event of the ObjectDataSource. But of course I dont want to change the generated code.

Am I doing this the wrong way?
Coordinator
Apr 11, 2008 at 3:51 AM
SvanurK,

It doesn't sound like you are doing anything wrong. This looks like a bug in the framework. I will look into it, and fix it.

Thanks for the catch.

Joel
Apr 11, 2008 at 10:10 AM
Edited Apr 14, 2008 at 5:06 PM
Hello Ross!
Thank you for your reply.

I noticed that your Insert and Update procedures return a @table with all inserted/updated values in a single row.
Would it be possible to return this data as an instance of the current class ? Say the current class name is Order, then there would be a function called 'ExecuteOrder' in the SqlHelper class.

Then I could get the object from the ObjectDataSourceStatusEventArgs.ReturnValue property of an 'Inserted' event and cast it to an Order instance.


Thanks,
Svanur.