Question What is the best way to copy an array into a DataGrid?

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
167
Programming Experience
Beginner
Does anyone know the best way to copy an array into a DataGrid?? Also, what's the best method for Clearing all records from a data table?
 
Last edited:
An array of what? Is it really a DataGrid or is is it actually a DataGridView? Generally speaking, the best way to display any list in a grid is to assign it to the grid's DataSource property.

Just like any collection, you clear the Rows collection of a DataTable by calling its Clear method. That said, that will remove the rows as though they were never added. If what you actually want is to delete each record from the database then you need to loop through the rows and call Delete on each one, then use a data adapter to Update the database.
 
Back
Top