Problem with updating record with objectdatasource

  • Thread starter Thread starter fig000
  • Start date Start date
F

fig000

Hi,

I'm new to the new asp.net :-). I've set up a web form with a grid
and an objectdatasource (in my presentation layer). I have a seperate
datalayer project which has webservices in it. I tell the
objectdatasource what my update method is by refering to a web service
method through a web reference in the presentation layer (The webmethod

IS my update method).


This almost works. What I've found is that the web service parameters

are all of the fields in the grid (including the pk) and an original
version of the pk is tacked on to the end of the paramaters. Before I
did this I was getting errors telling me that it couldn't find a
non-generic ..I'm sure you've all seen the error.


Once I got rid of that error by giving the web method the signature
the objectdatasource wanted, I still couldn't update data. I tried just

running the web service by itself which worked. However when I ran the
code (gridview and all) and checked the parameters coming into the
webservice, I found that the original version of the pk was zero. I
changed it in the debugger to the be same value of the pk parameter
being passed and I was able to save my changes.


I'm not sure what is wrong here. Is there a setting somewhere that
will pass the correct value of the original pk from the
objectdatasource to my web method?


Thanks,
Fig


Reply »
 
Common issue with using ObjectDataSource control with custom objects. One
thing I have found out is that the name of the parameter variables that your
web service method accepts should be identical to the names of the bound
column names. If you have a colum data field called ID and firstName (
these are listed in the objectDataSource parameters) then your webservice
method should have these exact parameter names void update (int ID, string
firstName ), etc.

Also, the objectDataSource sends both the old values and the new values to
each method it calles. To remove that you must set the
OldValuesParameterFormatString of the ObjectDataSource to {0} instead of
original_{0}

Hopefully, this may provide you with some assistance.


Hi,

I'm new to the new asp.net :-). I've set up a web form with a grid
and an objectdatasource (in my presentation layer). I have a seperate
datalayer project which has webservices in it. I tell the
objectdatasource what my update method is by refering to a web service
method through a web reference in the presentation layer (The webmethod

IS my update method).


This almost works. What I've found is that the web service parameters

are all of the fields in the grid (including the pk) and an original
version of the pk is tacked on to the end of the paramaters. Before I
did this I was getting errors telling me that it couldn't find a
non-generic ..I'm sure you've all seen the error.


Once I got rid of that error by giving the web method the signature
the objectdatasource wanted, I still couldn't update data. I tried just

running the web service by itself which worked. However when I ran the
code (gridview and all) and checked the parameters coming into the
webservice, I found that the original version of the pk was zero. I
changed it in the debugger to the be same value of the pk parameter
being passed and I was able to save my changes.


I'm not sure what is wrong here. Is there a setting somewhere that
will pass the correct value of the original pk from the
objectdatasource to my web method?


Thanks,
Fig


Reply »
 
Back
Top