Updating a RadGrid with a collection as the DataSource

2 posts, 0 answers
  1. Jay
    Jay avatar
    10 posts
    Member since:
    Apr 2015

    Posted 19 Jan 2017 Link to this post

    I am testing out the Telerik RadGrid to see if it can replace a custom Silverlight grid we have in our product.  The problem is that our product reads the data from CouchDB as a JSON file which we de-serialize into a class (stored in a Session variable) that contains collections (System.Collections.Generic.List) of other classes.  I bind one of these sub-collections to the RadGrid.DataSource, depending on what I need to display and call RadGrid.DataBind().

    Everything there works fine, except when I go to update the InPlace grid values with the RadGrid_UpdateCommand event.  I only get the old values and not the updated ones, possibly due to the PostBack resetting the values. I have found other postings of people with this issue, but they are all binding to a DataSource object like SqlDataSource.

    Is it possible to update a collection bound to the RadGrid datasource?

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2379 posts

    Posted 24 Jan 2017 Link to this post

    Hi Jay,

    Note that the DataBind() method is used for simple data binding. This type of binding is suitable only for the most simple scenarios where features like paging, sorting, filtering, etc. will not be used in RadGrid.

    I would recommend to bind the grid via the NeedDataSource event. Make sure that you set the DataSource property of the Grid only in the NeedDataSource handler. If you need to rebind the grid explicitly you can use Rebind(). Moreover, you need to ensure that DataBind() method for the Grid is not called anywhere in the code.

    Please examine the following resources that illustrate how you can bind RadGrid via NeedDataSoucre. The demo also illustrate how you can implement manual CRUD operations via the UpdateCommand/InsertCommand/DeleteCommand events.



    Regards,
    Viktor Tachev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top