Simple GridView Problem

Discussion in 'ASP .Net' started by Tina, Jul 25, 2006.

  1. Tina

    Tina Guest

    I'm trying to do something very straightforward in a 2.0 asp.net app with a
    GridView - ObjectDataSource - DataSet.

    I create a DataSet that accesses the NorthWind Customers Table - all columns
    and I choose to generate all methods and updates. I connect this DataSet to
    an ObjectDataSource and connect my DataView to the ObjectDataSource. (I did
    not opt for optimistic concurrency) It displays just fine. Then I try to
    change an address field in a row and get the error pasted below. The update
    command that was generated is also pasted below. This is stuff right out of
    textbooks. What is wrong?

    Thanks,
    T

    ObjectDataSource 'ods2' could not find a non-generic method 'Update' that
    has parameters: CompanyName, ContactName, ContactTitle, Address, City,
    Region, PostalCode, Country, Phone, Fax, original_CustomerID.


    UPDATE Customers
    SET CustomerID = @CustomerID, CompanyName = @CompanyName,
    ContactName = @ContactName, ContactTitle = @ContactTitle, Address =
    @Address,
    City = @City, Region = @Region, PostalCode =
    @PostalCode, Country = @Country, Phone = @Phone, Fax = @Fax
    WHERE (CustomerID = @Original_CustomerID)
    Tina, Jul 25, 2006
    #1
    1. Advertising

  2. Tina

    Ron Guest

    "Tina" <> wrote in message
    news:ek%...
    > I'm trying to do something very straightforward in a 2.0 asp.net app with
    > a GridView - ObjectDataSource - DataSet.
    >
    > I create a DataSet that accesses the NorthWind Customers Table - all
    > columns and I choose to generate all methods and updates. I connect this
    > DataSet to an ObjectDataSource and connect my DataView to the
    > ObjectDataSource. (I did not opt for optimistic concurrency) It displays
    > just fine. Then I try to change an address field in a row and get the
    > error pasted below. The update command that was generated is also pasted
    > below. This is stuff right out of textbooks. What is wrong?
    >
    > Thanks,
    > T
    >
    > ObjectDataSource 'ods2' could not find a non-generic method 'Update' that
    > has parameters: CompanyName, ContactName, ContactTitle, Address, City,
    > Region, PostalCode, Country, Phone, Fax, original_CustomerID.
    >
    >
    > UPDATE Customers
    > SET CustomerID = @CustomerID, CompanyName = @CompanyName,
    > ContactName = @ContactName, ContactTitle = @ContactTitle, Address =
    > @Address,
    > City = @City, Region = @Region, PostalCode =
    > @PostalCode, Country = @Country, Phone = @Phone, Fax = @Fax
    > WHERE (CustomerID = @Original_CustomerID)
    >


    Hi Tina.
    The problem could be caused by an incorrect setting in your
    ObjectDataSource.Have you made sure the ObjectDataSource is configured not
    to send original values together with your own parameters?
    The ObjectDataSource OldValuesParameterFormatString property should not be
    set if you want to send only your own parameters.
    HTH
    Ron.
    Ron, Jul 25, 2006
    #2
    1. Advertising

  3. Tina

    Tina Guest

    OldValuesParameterFormatString was set to Original_{0} so I set it to blank
    and the same thing happens.
    T

    "Ron" <> wrote in message
    news:...
    > "Tina" <> wrote in message
    > news:ek%...
    >> I'm trying to do something very straightforward in a 2.0 asp.net app with
    >> a GridView - ObjectDataSource - DataSet.
    >>
    >> I create a DataSet that accesses the NorthWind Customers Table - all
    >> columns and I choose to generate all methods and updates. I connect this
    >> DataSet to an ObjectDataSource and connect my DataView to the
    >> ObjectDataSource. (I did not opt for optimistic concurrency) It displays
    >> just fine. Then I try to change an address field in a row and get the
    >> error pasted below. The update command that was generated is also pasted
    >> below. This is stuff right out of textbooks. What is wrong?
    >>
    >> Thanks,
    >> T
    >>
    >> ObjectDataSource 'ods2' could not find a non-generic method 'Update' that
    >> has parameters: CompanyName, ContactName, ContactTitle, Address, City,
    >> Region, PostalCode, Country, Phone, Fax, original_CustomerID.
    >>
    >>
    >> UPDATE Customers
    >> SET CustomerID = @CustomerID, CompanyName = @CompanyName,
    >> ContactName = @ContactName, ContactTitle = @ContactTitle, Address =
    >> @Address,
    >> City = @City, Region = @Region, PostalCode =
    >> @PostalCode, Country = @Country, Phone = @Phone, Fax = @Fax
    >> WHERE (CustomerID = @Original_CustomerID)
    >>

    >
    > Hi Tina.
    > The problem could be caused by an incorrect setting in your
    > ObjectDataSource.Have you made sure the ObjectDataSource is configured not
    > to send original values together with your own parameters?
    > The ObjectDataSource OldValuesParameterFormatString property should not be
    > set if you want to send only your own parameters.
    > HTH
    > Ron.
    >
    Tina, Jul 25, 2006
    #3
  4. Tina

    Ron Guest

    "Tina" <> wrote in message
    news:%...
    > OldValuesParameterFormatString was set to Original_{0} so I set it to
    > blank and the same thing happens.
    > T
    >

    <snip>
    OK, Tina.
    Try removing the CustomerID = @CustomerID from your parameter list.
    I wonder why you are using an ObjectDataSource and a DataSet when normally
    an SqlDataSource works directly with a GridView. I set up an SqlDataSource
    and a GridView to view and update the Northwind Customer Table without any
    problem, but the Update SQL code in the SqlDataSource did not include a
    CustomerID = @CustomerID, because CustomerID is the primary key of the
    Customer table. So try changing your Update code to

    UPDATE Customers
    SET CompanyName = @CompanyName, ContactName = @ContactName,
    ContactTitle = @ContactTitle, Address = @Address, City = @City, Region =
    @Region, PostalCode = @PostalCode, Country = @Country, Phone = @Phone, Fax =
    @Fax
    WHERE (CustomerID = @Original_CustomerID)

    You may have to change the WHERE clause to

    WHERE (CustomerID = @CustomerID)

    If that does not fix the problem, I suggest using an SqlDataSource instead
    of the ObjectDataSource.

    HTH

    Ron.
    Ron, Jul 26, 2006
    #4
  5. Tina

    Colin40

    Joined:
    Jun 22, 2007
    Messages:
    1
    Try deleting OldValuesParameterFormatString="original_{0}" from the ObjectDataSource tag.
    Colin40, Jun 22, 2007
    #5
    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. Nalaka

    GridView in a GridView

    Nalaka, Nov 11, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    6,587
    Nalaka
    Dec 5, 2005
  2. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,944
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  3. Vik
    Replies:
    1
    Views:
    510
  4. HeavyMetal

    GridView RowCommand problem: GridView Nested in Repeater

    HeavyMetal, Aug 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    780
    HeavyMetal
    Aug 8, 2006
  5. dillon
    Replies:
    1
    Views:
    170
    higabe
    Nov 17, 2003
Loading...

Share This Page