all groups > dotnet windows forms databinding > september 2006 >
You're in the

dotnet windows forms databinding

group:

FormViewInsertedEventArgs.AffectedRows is always -1


FormViewInsertedEventArgs.AffectedRows is always -1 Baldie
9/29/2006 7:58:02 AM
dotnet windows forms databinding:
I'm using a form view together with a ObjectDataSource.

In the FormViewItemInserted event I check
if (1 == e.AffectedRows)

e being of type FormViewInsertedEventArgs

AffectedRows is always -1. No excption (e.Exception == null) is thrown and
the record is added to the database correctly.

I dont understand when this value is supposed to be set. I figured it used
the return value from the ObjectDataSource's Insert method but that dont seem
to be the case. The insert method i created returns an int that is the number
of rows affected by the database operation. No effect whatsoever on
FormViewInsertedEventArgs though.

Where does FormViewInsertedEventArgs.AffectedRows get it's value from when
using a ObjectData source?

Re: FormViewInsertedEventArgs.AffectedRows is always -1 Manu
9/29/2006 5:06:44 PM
Baldie,

the AffectedRows property always returns -1. Take a look here for more
information:

http://www.manuelabadia.com/blog/PermaLink,guid,eaa3eed8-f997-43c4-8c30-78c2f72d0c86.aspx

If you do not want to manually set the AffectedRows property you can
use my EODS component:

http://www.manuelabadia.com/products/EODS_features.aspx

that will work without having to write code if your insert, update and
delete operations return the number of rows affected

Best regards,
Manuel Abadia
http://www.manuelabadia.com

[quoted text, click to view]
Re: FormViewInsertedEventArgs.AffectedRows is always -1 Baldie
10/2/2006 1:01:01 AM
Thanks Manuel

Handling the events of the ObjectData source as you described solved my
problem.

protected void ObjectDataSource_Inserted(object sender,
ObjectDataSourceStatusEventArgs e)
{
e.AffectedRows = (int)e.ReturnValue;
AddThis Social Bookmark Button