Automatic operations with ObjectDataSource control

Thread is closed for posting
16 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 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. idjones
    idjones 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. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    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. Dan
    Dan 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. Dan
    Dan 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. jefflandry
    jefflandry 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. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    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. jefflandry
    jefflandry 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. Steve
    Admin
    Steve avatar
    10941 posts

    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. mmcintosh
    mmcintosh 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. ron.cicotte
    ron.cicotte 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. mmcintosh
    mmcintosh 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. Dan
    Dan 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. ron.cicotte
    ron.cicotte 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. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    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. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    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