Automatic operations with ObjectDataSource control

Thread is closed for posting
16 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 16 Oct 2006 Link to this post

    Requirements

    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    4.x and later



    2007.3.1428 and later

    .NET version

    2.0 and later

    Visual Studio version

    2005 and later

    Programming language

    C#, VB

    Browser support

    all supported by RadGrid for ASP .NET


    all browsers supported by RadControls for ASP .NET AJAX


    PROJECT DESCRIPTION
    This demo represents how to perform automatic operations (update/insert/delete) with ObjectDataSource control (part of ASP.NET 2.0). The main points are:
    • generate the source for the grid through typed dataset
    • enable the automatic operations for the control
    • configure from design-time the update/insert/delete parameters of the ObjectDataSource control.

    Note that you may need to modify the connection string (NorthwindConnectionString) in the web.config file of the web site to point to the Northwind SQL database.

  2. C8084531-FB18-4DE4-8075-8FC329488D40
    C8084531-FB18-4DE4-8075-8FC329488D40 avatar
    8 posts
    Member since:
    Aug 2006

    Posted 18 Nov 2006 Link to this post

    Thanks for this information,

    although I already have this working.

    The issue I have is when using the objectdatasource and automatic updates if I use a RadDatePicker to edit a datefield, the automatic updates don't work for this field.

    I can catch it in the

    RadGrid1_UpdateCommand

    and then modify the grid to
    e.Item.OwnerTableView.Items[e.Item.ItemIndex][column.UniqueName].Text

    have the correct value of the control.

    Although this gets overwritten, and the update doesn't go back.

    So unless I write an custom adapter to perform the updates for every object I can't find a way to automatically update the data.

    Any thoughts?

    Thanks

  3. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    Posted 20 Nov 2006 Link to this post

    Hi Ian,

    Can it be that you generate your date picker control as custom editor and have not assigned explicitly Id for it? If this is the case, please review this thread in our code library section which explains how to address the problem.
    If this does not help, I suggest you start a formal support ticket and attach a sample project which represents the issue. I will review your logic carefully and will get back to you with an appropriate explanation/fix.

    Kind regards,
    Stephen
    the telerik team
  4. 1337B49B-00D7-47A6-BA1E-40621978878E
    1337B49B-00D7-47A6-BA1E-40621978878E avatar
    28 posts
    Member since:
    Nov 2005

    Posted 29 Nov 2006 Link to this post

    The demo uses a SQL query in the dataset. However, when I reconfigure the dataset to use stored procedures I get the following error when I attempt to update:

    ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: LastName, FirstName, City, Address, Country, original_EmployeeID.

    I need to use stored procedures. Can you shed any light on this?

    Thanks
  5. 1337B49B-00D7-47A6-BA1E-40621978878E
    1337B49B-00D7-47A6-BA1E-40621978878E avatar
    28 posts
    Member since:
    Nov 2005

    Posted 30 Nov 2006 Link to this post

    Got this working -  extra parameters are generated in the the sproc and datasource. Once these are deleted, it all works fine.
  6. 750BAF4F-ED0E-4A49-894B-A65CE5CDB0AF
    750BAF4F-ED0E-4A49-894B-A65CE5CDB0AF avatar
    30 posts
    Member since:
    Feb 2007

    Posted 06 Feb 2007 Link to this post

    when i ran this it told me my windows user id didn't have access to the db.  How do I fix that?
  7. 445A32F6-0752-43F8-9809-688D6BB4CA80
    445A32F6-0752-43F8-9809-688D6BB4CA80 avatar
    559 posts
    Member since:
    Jan 2015

    Posted 07 Feb 2007 Link to this post

    Hello Jeff,

    Make sure your SQL Server's security settings allow your ASP.NET user (usually ASPNET or Network Service) to access the DB.

    I have seen SQL Server generate security errors when the user has no default DB set, so make sure that the user's default DB is set to something, say Northwind.

    Sincerely yours,
    Hristo Deshev
    the telerik team
  8. 750BAF4F-ED0E-4A49-894B-A65CE5CDB0AF
    750BAF4F-ED0E-4A49-894B-A65CE5CDB0AF avatar
    30 posts
    Member since:
    Feb 2007

    Posted 07 Feb 2007 Link to this post

    didn't have the sample databases installed in the sql server.

    Thanks,
    Jeff Landry
  9. 3BD6F94B-4C03-46D3-8568-9982F1F201BF
    3BD6F94B-4C03-46D3-8568-9982F1F201BF avatar
    10940 posts
    Member since:
    May 2014

    Posted 20 Feb 2007 Link to this post

    Hi guys,

    We have attached the NorthWind database to this code library so that you can use it for the project directly.

    Kind regards,
    Steve
    the telerik team
  10. 64A3FFAB-4C87-464C-8FC8-64B56B68BC84
    64A3FFAB-4C87-464C-8FC8-64B56B68BC84 avatar
    2 posts
    Member since:
    Mar 2007

    Posted 07 Mar 2007 Link to this post

    We use Data Access Layers-DALs that provide public non-instance methods for updating, inserting and deleting data.  Can you point me to an example where the RAD Grid is used in this environment using ObjectDataSources?

    Thanks!
  11. 55881AC5-7F95-4918-A0AA-47E7F194566F
    55881AC5-7F95-4918-A0AA-47E7F194566F avatar
    14 posts
    Member since:
    Aug 2007

    Posted 27 Sep 2007 Link to this post

    I am having the same problem and I have still been unable to get this to work using a stored procedure.  The sample code uses a text query but when I change it to a stored procedure do I need to use the Data Key.  I don't need the "original_"id in my stored procedure siince I never update the key field and I am already passing the id in my parameter set.

    I have even tried adding the "original_id" to my update parameter set but still no luck.  I get no error message but the data is not updated.

    Can you share with us how you got the ObjectDataSource to work with the stored procedure?

    Thanks

    -ron cicotte
  12. 64A3FFAB-4C87-464C-8FC8-64B56B68BC84
    64A3FFAB-4C87-464C-8FC8-64B56B68BC84 avatar
    2 posts
    Member since:
    Mar 2007

    Posted 27 Sep 2007 Link to this post

    Wow, that was a blast from the past!  I had to go back and look at that 6 month old code.

    Unfortunately we never got it to work and abandoned the idea in favor of an actual edit web form.  Sorry I couldn't help!

    Thanks,

    Scott McIntosh
  13. 1337B49B-00D7-47A6-BA1E-40621978878E
    1337B49B-00D7-47A6-BA1E-40621978878E avatar
    28 posts
    Member since:
    Nov 2005

    Posted 28 Sep 2007 Link to this post

    Hi Ron,

    What I do to get the ObjectDataSOurce to work with a SP is:

    1. Create a Dataset with Insert / Update / Deletes as normal

    2. Alter the Update and Delete SP: remove the param with 'original_' and remove all references to it in the SP

    3. Go back into the Dataset, right click > configure the Table Adaptor and run through this process again, ckicking next..next..
    *Make sure you 'Save All' at this point, as you need to save both the .xsd and .xss files

    4. Now set up your ObjectDataSource object as normal

    5. In the ObjectDataSource properties, remove the value 'original_{0}' from the property 'OldValuesParameterFormatString', leaving the property blank.

    The update & delete method will now (hopefully) work!
    I hope this helps.

    Dan.
  14. 55881AC5-7F95-4918-A0AA-47E7F194566F
    55881AC5-7F95-4918-A0AA-47E7F194566F avatar
    14 posts
    Member since:
    Aug 2007

    Posted 28 Sep 2007 Link to this post

    Thanks very much Dan!  I will try this and get back to you.  It's nice to have clear step by step instructions for this.  I've spent hours trying to get this to work.
  15. 979E5D40-F4EA-42C2-B17F-E45A822E9AA6
    979E5D40-F4EA-42C2-B17F-E45A822E9AA6 avatar
    1911 posts
    Member since:
    Jan 2017

    Posted 11 Mar 2008 Link to this post

    Hello,

    We have updated the project with the Telerik.Web.UI version. The database is also added to the project so that one can just download the sample and run it locally.

    Kind regards,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  16. DF7D1A30-6166-46E3-8A25-1BDF36B1ACD1
    DF7D1A30-6166-46E3-8A25-1BDF36B1ACD1 avatar
    1155 posts
    Member since:
    May 2017

    Posted 23 Oct 2012 Link to this post

    For your convenience we have modified the code library

    DESCRIPTION
    This demo represents how to perform automatic operations (update/insert/delete) with ObjectDataSource control (part of ASP.NET 3.5). The main points are:
    • generate the source for the grid through LINQ to SQL
    • enable the automatic operations for the control
    • configure from design-time the update/insert/delete parameters of the ObjectDataSource control.

    All the best,
    Angel Petrov
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.