AC25
AC25

Reputation: 423

Remove datarow with linq

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.

Upvotes: 0

Views: 449

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564433

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

theDataTable.Rows.RemoveAt(rowIndex);
theDataTable.AcceptChanges();

Upvotes: 4

Related Questions