C# Convert DataGridView to DataTable

I saw some websites which show how to bind dataTable to dataGridView.

But the opposite way was not seen.

I leave as a memorandum how to convert dataGridView to dataTable.

Code to Store DataGridView into DataTable

Here is the code.

※ Not considered when NULL value is in DataGridView.

If necessary, add code to fill in “0” or “” for NULL value.

Unexpectedly, I think that it is convenient because there are times when I want to import to DataTable and update or check data extracted from DB.


Your email address will not be published. Required fields are marked *