UpdateFieldValue Method
The UpdateFieldValue method updates a single field value in an IDataSet
by addressing the target cell using tableName, rowIndex, and columnName.
This is a dataset-level convenience wrapper around the row indexer
(dataRow[columnName] = value). It performs table lookup, range checking, and column validation
before applying the value to the row. The underlying row indexer is responsible for state-aware behavior,
such as guarding against updates of deleted rows and transitioning row state to Modified
when appropriate.
/// <summary>
/// Updates field value
/// </summary>
/// <typeparam name="T">Value type</typeparam>
/// <param name="dataSet">Data set</param>
/// <param name="tableName">Table name</param>
/// <param name="rowIndex">Row index</param>
/// <param name="columnName">Column name</param>
/// <param name="fieldValue">Field value</param>
/// <exception cref="KeyNotFoundException">Exception is thrown if dataset does not contain a table with specified name or column with specified name in that table</exception>
/// <exception cref="ArgumentOutOfRangeException">Exception is thrown if table does not have row with specified index</exception>
public static void UpdateFieldValue<T>(this IDataSet? dataSet, string tableName, int rowIndex, string columnName, T? fieldValue)
Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll
dataSet is null, returns immediately.GetTable. If the table is missing, the method throws.
rowIndex is within bounds.
columnName.
dataRow[columnName] = fieldValue.
Row state transitions and deleted-row guards are enforced by the row implementation.
// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2. Create a table and add a row
IDataTable employeeTable = dataSet.AddNewTable("Employee");
employeeTable.AddColumn("Id", DataTypeNames.INT32);
employeeTable.AddColumn("FirstName", DataTypeNames.STRING);
employeeTable.AddColumn("LastName", DataTypeNames.STRING);
IDataRow employeeRow = employeeTable.AddNewRow();
employeeRow["Id"] = 1;
employeeRow["FirstName"] = "John";
employeeRow["LastName"] = "Doe";
employeeTable.AcceptChanges();
// 3. Update a field value using the data set extension
dataSet.UpdateFieldValue("Employee", 0, "LastName", "Smith");
UpdateFieldValue is typically used when you do not have a direct reference to the row.
If you already have an IDataRow, you can assign values via the row indexer directly.
TryGetTable / validation logic before calling this method.
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.