telerik

Submission
Home  Community  CodeLibrary home  RadControls for ASP.NET and ASP.NET AJAX  RadGrid  Automatic operations with ObjectDataSource control


 Requirements 
 RadGrid version
Telerik.Web.UI
 4.0.0+
2007_3_1425+
 .NET version  2.0
 Visual Studio version  2005
 programming language

Codeless declarative binding

 browser support  all browsers supported by r.a.d.grid
To convert code from posted projects Telerik online converter

 
  • 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.



  • idjones | #
    11/18/2006 4:36:38 PM

    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



    telerik | #
    11/20/2006 3:54:40 AM
    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


    Dan | #
    11/29/2006 4:26:11 AM
    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


    Dan | #
    11/30/2006 10:01:12 AM
    Got this working -  extra parameters are generated in the the sproc and datasource. Once these are deleted, it all works fine.

    jefflandry | #
    2/6/2007 7:57:51 PM
    when i ran this it told me my windows user id didn't have access to the db.  How do I fix that?

    telerik | #
    2/7/2007 1:12:02 AM
    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


    jefflandry | #
    2/7/2007 5:32:40 PM
    didn't have the sample databases installed in the sql server.

    Thanks,
    Jeff Landry


    telerik | #
    2/20/2007 2:58:08 AM
    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


    mmcintosh | #
    3/7/2007 4:04:23 PM
    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!


    ron.cicotte | #
    9/27/2007 5:24:28 PM
    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


    mmcintosh | #
    9/27/2007 6:54:46 PM
    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


    Dan | #
    9/28/2007 3:21:03 AM
    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.


    ron.cicotte | #
    9/28/2007 12:42:01 PM
    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.

    telerik | #
    3/11/2008 7:16:14 AM
    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