RemoveRow Method

Overview

The RemoveRow extension method removes a row from a table in an IDataSet.

It is a convenience wrapper over the table-level remove operations. The method locates the table by name and delegates to IDataTable.RemoveRow(...).

Two overloads are provided: remove by row index, and remove by row reference (state-aware semantics).

Declaration

/// <summary>
/// Removes row from table
/// </summary>
/// <param name="dataSet">Data set</param>
/// <param name="tableName">Table name</param>
/// <param name="rowIndex">Row index</param>
/// <exception cref="KeyNotFoundException">Exception is thrown if dataset does not contains a table with specified name</exception>
/// <exception cref="ArgumentOutOfRangeException">Exception is thrown if table does not have row with specified index</exception>
public static void RemoveRow(this IDataSet? dataSet, string tableName, int rowIndex)

/// <summary>
/// Removes row from table using state-aware semantics.
/// </summary>
/// <param name="dataSet">Data set</param>
/// <param name="tableName">Table name</param>
/// <param name="dataRow">Data row to remove</param>
/// <exception cref="KeyNotFoundException">Thrown if dataset does not contain a table with specified name</exception>
public static void RemoveRow(this IDataSet? dataSet, string tableName, IDataRow? dataRow)

Namespace and Assembly

Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll

Usage Example

// 1. Create data set
IDataSet dataSet = DataSetFactory.CreateDataSet();

// 2. Add Department table to data set
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32, false, true);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);

// 3. Add two rows to Department table
IDataRow departmentFirstDataRow = departmentDataTable.AddNewRow();
departmentFirstDataRow["Id"] = 1;
departmentFirstDataRow["Name"] = "Sales";

IDataRow departmentSecondDataRow = departmentDataTable.AddNewRow();
departmentSecondDataRow["Id"] = 2;
departmentSecondDataRow["Name"] = "Engineering";

// 4a. Remove by index
dataSet.RemoveRow("Department", 0);

// 4.b. Remove by row reference (state-aware semantics)
dataSet.RemoveRow("Department", departmentSecondDataRow);

 

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