ADO.NET

ADO.NET Projects

ADO.NET Project 1

ADO.NET Examples

Examples

DataTable Events
Previous Home Next

DataTable exposes a set of events and the events can be captured and handled in order to update the user interface, or to validate edits or deletes before they are committed. Not including the event inherited from MarshalByValueComponent.Disposed, there are nine events in all, and they all work in more-or-less the same way, with similar arguments.

System.Data.DataTable Events

Event Description
ColumnChanging Occurs when a value is being changed in the specified DataColumn in DataRow.
ColumnChanged Occurs after a value has been changed in the specified DataColumn in a DataRow.
RowChanging Occurs when a DataRow is changing. This event will fire each time a change is made to the DataRow, after the ColumnChanging event has fired.
RowChanged Occurs after a DataRow has been changed successfully.
TableClearing Occurs when the table is being cleared.
TableCleared Occurs after the table has been cleared.
RowDeleting Occurs when a DataRow is about to be deleted.
TableNew Row Occurs right after a new row has been generated.
RowDeleted Occurs after a DataRow is successfully deleted from the DataTable.

 

Each of the DataTable events works in the same fashion. Handlers for the column-related events (ColumnChanging and ColumnChanged) receive a DataColumnChangeEventArgs object, which exposes three properties.

DataColumnChangeEventArgs Properties

Property Description
Column Get DataColumn object with the changing value.
Proposed Value Gets or sets the proposed value—that is, the new value being assigned to the column. In a ColumnChanging event handler
Row Gets the DataRow object with the changing value

The handlers for the row-related events other than the TableNewRow (i.e., RowChanging, RowChanged, RowDeleting, and RowDeleted) take a DataRowChangeEventArgs object, which exposes just two properties

DataRowChangeEventArgs Properties

Property Description
Action Gets the action (added, changed, deleted, etc.) that will occur/has occurred on the DataRow.
Row Gets the DataRow object upon which the action will occur/has occurred.

s
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: