Formview and ObjectDataSource Update method

Formview and ObjectDataSource Update method

am 07.01.2008 19:36:48 von 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!

Re: Formview and ObjectDataSource Update method

am 07.01.2008 19:51:26 von Phil H

On 7 Jan, 18:36, Aamir Ghanchi wrote:
> 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 =A0I 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?

Re: Formview and ObjectDataSource Update method

am 07.01.2008 22:56:20 von Aamir Ghanchi

Hi Phil,

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

Thanks.

On Jan 7, 12:51=A0pm, Phil H wrote:
> On 7 Jan, 18:36, Aamir Ghanchi wrote:
>
>
>
>
>
> > 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 =A0I 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?- Hide quoted text -
>
> - Show quoted text -