This is a migrated thread and some comments may be shown as answers.

Updating a RadGrid with a collection as the DataSource

1 Answer 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 19 Jan 2017, 04:59 PM

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?

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 24 Jan 2017, 11:47 AM
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.
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or