DeleteRowAt Method
The DeleteRowAt method deletes a row from an data table by its zero-based index.
It is a convenience wrapper around DeleteRow that performs bounds checking and resolves
the target IDataRow automatically.
The deletion itself is state-aware and is delegated to DeleteRow(IDataRow),
which applies different behavior depending on the row's DataRowState.
/// <summary>
/// Deletes row from table by row index
/// </summary>
/// <param name="dataTable">Data table</param>
/// <param name="rowIndex">Row index</param>
/// <exception cref="ArgumentOutOfRangeException">Exception is thrown if table does not have row with specified index</exception>
public static void DeleteRowAt(this IDataTable? dataTable, int rowIndex)
Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll
dataTable is null, returns immediately.rowIndex is less than 0 or greater than or equal to dataTable.Rows.Count,
returns immediately.
rowIndex and delegates deletion to
dataTable.DeleteRow(dataRow).
// 1. Create an empty data set and a table
IDataSet dataSet = DataSetFactory.CreateDataSet();
IDataTable employeeDataTable = dataSet.AddNewTable("Employee");
employeeDataTable.AddColumn("Id", DataTypeNames.INT32);
employeeDataTable.AddColumn("FirstName", DataTypeNames.STRING);
employeeDataTable.AddColumn("LastName", DataTypeNames.STRING);
// 2. Add a row in Added state
IDataRow employeeDataRow1 = employeeDataTable.AddNewRow();
employeeDataRow1["Id"] = 1;
employeeDataRow1["FirstName"] = "John";
employeeDataRow1["LastName"] = "Doe";
// 3. Add a row in Unchanged state
IDataRow employeeDataRow2 = employeeDataTable.AddNewRow();
employeeDataRow2["Id"] = 2;
employeeDataRow2["FirstName"] = "Sara";
employeeDataRow2["LastName"] = "Gor";
employeeDataRow2.AcceptChanges();
// 3. Add a row in Modified state
IDataRow employeeDataRow3 = employeeDataTable.AddNewRow();
employeeDataRow3["Id"] = 1;
employeeDataRow3["FirstName"] = "Paul";
employeeDataRow3["LastName"] = "Carry";
employeeDataRow3.AcceptChanges();
employeeDataRow3["FirstName"] = "Tom";
4. Call DeleteRowAt for each row
// Modifies row marked as deleted
employeeDataTable.DeleteRowAt(2);
// Unchanged row marked as deleted
employeeDataTable.DeleteRowAt(1);
// Added row removed from table
employeeDataTable.DeleteRowAt(0);
Table of Content POCO DataSet DataTable Extensions Group DataTable Members
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.