How can I delete from a GridView when DataSource is a DataTable?
- by David
My DataSource is a DataTable populated from file system data in Page_Load. There is no database. How can I remove rows from the DataTable and rebind? I thought this had to be done in the GridView_RowCommand "Delete" section...
if(e.CommandName == "Delete")
...
When I try to access the DataRow's within
//get the datatable
DataTable dt = this.gridCPCP.DataSource as DataTable;
// Delete the record
foreach (DataRow dr in dt.Rows)
{
....
dt is null. How do I reference the DataTable when deleting records?