RemoveRowAt Method

Overview

The RemoveRowAt method removes row at specified position from a data table.

Declarations

/// <summary>
/// Removes row at specified position from data table
/// </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 RemoveRow(this IDataTable? dataTable, int rowIndex)

Namespace and Assembly

Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll

Usage Example

// 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 RemoveRowAt on each row
// Modified row removed from table
employeeDataTable.RemoveRowAt(2);

// Unchanged row removed from table
employeeDataTable.RemoveRowAt(1);

// Added row removed from table
employeeDataTable.RemoveRowAt(0);

 

Table of Content POCO DataSet API References POCO DataSet Types 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.