0

I have a datatable in which I have the index number of the row that i want to delete using linq. I cant seem to get this to work properly because I am writing

int RowIndex = 3;  
DataTable.AsEnumerable().ToList().RemoveAt(RowIndex);
DataTable.AcceptChanges();

There is no error but it does not remove the row.

Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
AC25
  • 413
  • 1
  • 7
  • 23

1 Answers1

4

You don't need LINQ for this. Just remove it directly:

theDataTable.Rows.RemoveAt(rowIndex);
theDataTable.AcceptChanges();
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373