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

How to extract RadGrid EditableItem into a DataTable?

1 Answer 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 31 May 2016, 08:33 PM

Is it possible to extract the edited row from a RadGrid into a DataTable object?

The examples I've seen online show how to extract the data into a HashTable, but once you do that, you lose the data type (string, datetime, ect). We're building a generic grid that can display different tables, so we don't want to have to hard code the columns/data types. If the data is in a DataTable, then it can be passed directly to a SQL stored procedure that accepts a Table Value Parameter.

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 03 Jun 2016, 11:49 AM
Hello Matthew,

I guess you are referring to the ExtractValues() method that can be used to retrieve the values from an edited item in the grid. The parameter for the method is an IDictionary, this is why the examples are using Hashtable.

In order to pass the new values to the database I can suggest different approaches.

  • Use the key/value pairs in the Hashtable and build the SQL query for update manually. Note that by default the keys will be the column UniqueNames and they will likely match the name of the field in the database (unless you modified them explicitly).
  • Use the Hashtable and convert it to a DataTable like described in this article
  • Use custom logic to retrieve the values from the grid cells and construct the DataTable manually. If you would like additional information on how to access the cell values you will like this article.



Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or