UpdateFieldValue Method

Overview

The UpdateFieldValue method updates a field value in an observable data set by writing through an IObservableDataRow. This guarantees that all observable notifications (cell change, row state change, and view updates) are raised correctly.

This method exists as a convenience wrapper for scenarios where the caller only knows the table name, row index, and column name, and does not already have a reference to the observable row.

Declaration

/// <summary>
/// Updates field value in an observable data set by writing through the observable row.
/// This ensures that observable events (row / cell notifications) are raised and views stay consistent.
/// </summary>
/// <typeparam name="T">Value type</typeparam>
/// <param name="observableDataSet">Observable 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 data set does not contain a table with specified name</exception>
/// <exception cref="ArgumentOutOfRangeException">Exception is thrown if rowIndex is out of range</exception>
public static void UpdateFieldValue<T>(this IObservableDataSet? observableDataSet, string tableName, int rowIndex, string columnName, T? fieldValue)

Namespace and Assembly

Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll

Usage Example

// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. Create Department observable data table with one row
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);

IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Reception";

// 3. Call GetFieldValue method and observe "Reception" as a name
string? deprtmentName = observableDataSet.GetFieldValue<string>("Department", 0, "Name");

// 4. Call UpdateFieldValue method and verify that vauls changed
observableDataSet.UpdateFieldValue<string>("Department", 0, "Name", "Emergency");

// 5. Call GetFieldValue method and observe "Emergency" as a name
deprtmentName = observableDataSet.GetFieldValue<string>("Department", 0, "Name");

 

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