Item[string] Indexer
The Item[string] indexer allows you to get or set the current value
of a data field of an observable data row by column name. This indexer provides convenient access
to row values using array-like syntax.
Reading a value using the indexer returns null if the specified
column does not exist or if the stored value is null.
Writing a value using the indexer updates the row value and may change the
row DataRowState. If the row is in the Unchanged state,
assigning a different value causes the framework to capture original values
and mark the row as Modified.
Namespace: PocoDataSet.ObservableData
Assembly: PocoDataSet.ObservableData.dll
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create Department observable table
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Add observable data row to Department observable table in Unchanged state by calling AcceptChanges method
IObservableDataRow departmentObservableDataRow1 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow1["Id"] = 1;
departmentObservableDataRow1["Name"] = "Marketing";
departmentObservableDataRow1.AcceptChanges();
// 4. Subscribe to all events of the observable data row
departmentObservableDataRow1.DataFieldValueChanged += DepartmentObservableDataRow1_DataFieldValueChanged;
departmentObservableDataRow1.PropertyChanged += DepartmentObservableDataRow1_PropertyChanged;
departmentObservableDataRow1.RowStateChanged += DepartmentObservableDataRow1_RowStateChanged;
// 5. Change any value of the observable data row and observe that all three events were raised and handled
departmentObservableDataRow1["Name"] = "Reception";
private void DepartmentObservableDataRow1_DataFieldValueChanged(object? sender, DataFieldValueChangedEventArgs e)
{
// columnName = "Name"
string columnName = e.ColumnName;
}
private void DepartmentObservableDataRow1_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// propertyName = "Name"
string propertyName = e.PropertyName;
}
private void DepartmentObservableDataRow1_RowStateChanged(object? sender, RowStateChangedEventArgs e)
{
// e.OldState is Unchanged
DataRowState oldState = e.OldState;
// e.NewState is Modified
DataRowState newState = e.NewState;
}
Table of Content POCO DataSet API References ObservablePOCO DataSet Types ObservableDataRow 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.