Formview and ObjectDataSource Update method

Discussion in 'ASP .Net' started by Aamir Ghanchi, Jan 7, 2008.

  1. 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!
     
    Aamir Ghanchi, Jan 7, 2008
    #1
    1. Advertising

  2. Aamir Ghanchi

    Phil H Guest

    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  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?
     
    Phil H, Jan 7, 2008
    #2
    1. Advertising

  3. Hi Phil,

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

    Thanks.

    On Jan 7, 12:51 pm, 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  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?- Hide quoted text -
    >
    > - Show quoted text -
     
    Aamir Ghanchi, Jan 7, 2008
    #3
  4. Aamir Ghanchi

    Phil H Guest

    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).
    --
    Phil Hegedusich
    Senior P/A
    IIMAK
    ----
    A skeleton walks into a bar and says, "I need a beer and a mop."


    "Aamir Ghanchi" wrote:

    > Hi Phil,
    >
    > Yes it is a unique key and is in the DataKeyNames property of the
    > Formview.
    >
    > Thanks.
    >
    > On Jan 7, 12:51 pm, 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 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?- Hide quoted text -
    > >
    > > - Show quoted text -

    >
    >
     
    Phil H, Feb 5, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFiYmxlcg==?=

    FormView update not updating with ObjectDataSource

    =?Utf-8?B?RGFiYmxlcg==?=, Apr 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    9,383
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 13, 2006
  2. Fred Dag
    Replies:
    0
    Views:
    1,697
    Fred Dag
    Sep 18, 2006
  3. kidders
    Replies:
    0
    Views:
    607
    kidders
    Jan 23, 2007
  4. Afshar
    Replies:
    0
    Views:
    372
    Afshar
    Apr 24, 2007
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    269
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page