Formview and ObjectDataSource Update method

A

Aamir Ghanchi

Hi,

Why does the Update method of an ObjectDataSource class requires
parameters for each of the Bind input controls of a FormView?

I have a class (say MyObjectDataSource) that is being used as an
ObjectDataSource for a FormView control. MyObjectDataSource has public
properties that correspond to db table columns and are also used to <
%# Bind("")%> Input controls in the formview declaratively.
There is an Update method in MyObjectDataSource that requires a
parameter for each and every Bind server controls. Otherwise I get a
server error that reads something like this

ObjectDataSource 'MyObjectDataSource' could not find a non-generic
method 'MyUpdateMethod' that has parameters: param1, pram2 and on and
on till it lists all the public properties to which the server
controls are bind.

I thought It was a given that the Update method should inherently know
about the Bind controls as they are bind to the public properties in
the same class of which the Update method is part of.

Am I doing something wrong or is there a need for design improvement
in Asp .Net in this regard.

thanks!
 
P

Phil H

Hi,

Why does the Update method of an ObjectDataSource class requires
parameters for each of the Bind input controls of a FormView?

I have a class (say MyObjectDataSource) that is being used as an
ObjectDataSource for a FormView control. MyObjectDataSource has public
properties that correspond to db table columns and are also used to <
%# Bind("")%> Input controls in the formview declaratively.
There is an Update method in MyObjectDataSource that requires a
parameter for each and every Bind server controls. Otherwise  I get a
server error that reads something like this

ObjectDataSource 'MyObjectDataSource' could not find a non-generic
method 'MyUpdateMethod' that has parameters: param1, pram2 and on and
on till it lists all the public properties to which the server
controls are bind.

I thought It was a given that the Update method should inherently know
about the Bind controls as they are bind to the public properties in
the same class of which the Update method is part of.

Am I doing something wrong or is there a need for design improvement
in Asp .Net in this regard.

thanks!

Hi

Does the data row being updated have a unique key, and if so is it
named in the DataKeyNames property of the Formview?
 
A

Aamir Ghanchi

Hi Phil,

Yes it is a unique key and is in the DataKeyNames property of the
Formview.

Thanks.
 
P

Phil H

Hi Aamir,

I'm getting the same behavior with the Update AND Insert methods.
Apparently the underlying code expects both the method parameters AND the
bound controls, so if you have a bound control that's named differently from
the parameter, it wants both to appear in a method signature. The quick
workaround is to create a process component method that contains all of the
expected parameters, and simply do nothing with the extraneous parameter
values. The good way is to match up bound control names with the parameter
names (I think; I'm still playing around with this).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top