How to extract RadGrid EditableItem into a DataTable?

2 posts, 0 answers
  1. Matthew
    Matthew avatar
    3 posts
    Member since:
    May 2016

    Posted 31 May Link to this post

    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.

  2. Viktor Tachev
    Viktor Tachev avatar
    1438 posts

    Posted 03 Jun Link to this post

    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.

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top