How can I delete from a GridView when DataSource is a DataTable?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-05-18T13:47:49Z
Indexed on
2010/05/18
13:50 UTC
Read the original article
Hit count: 286
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?
© Stack Overflow or respective owner