NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Working with DataTable Events

The DataTable provides a series of events that can be processed by the user's code. These events include:

Adding the event handler to the event.

[VB]
workTable.AddOnColumnChanging _
(New System.Data.DataColumnChangeEventHandler(AddressOf me.MyColChanging))
workTable.AddOnRowChanging _
(New System.Data.DataRowChangeEventHandler(AddressOf me.MyRowChanging))
workTable.AddOnRowChanged _
(New System.Data.DataRowChangeEventHandler(AddressOf me.MyRowChanged))

Private Sub MyColChanging _
(ByVal sender As Object, ByVal e As DataColumnChangeEventArgs)

End Sub

Private Sub MyRowChanging _
(ByVal sender As Object, ByVal e As DataRowChangeEventArgs)

'Add this to capture the row changing event
 Console.WriteLine("Adding row " + e.Row[0].ToString())

End Sub

Private Sub MyRowChanged _
(ByVal sender As Object, ByVal e As DataRowChangeEventArgs)
   If e.Action = Delete Then
      Console.WriteLine("deleting row " & e.Row(0).ToString)
   End If
End Sub
[C#]
workTable.AddOnColumnChanging(new DataColumnChangeEventHandler(MyColChanging));
workTable.AddOnRowChanging(new DataRowChangeEventHandler(MyRowChanging));
workTable.AddOnRowChanged(new DataRowChangeEventHandler(MyRowChanged));


Public void MyColChanging(object sender, DataColumnChangeEventArgs e)
{
}

public void MyRowChanging(object sender, DataRowChangeEventArgs e) {
 //Add this to capture the row changing event
 Console.WriteLine("Adding row " + e.Row[0].ToString());
}

public void MyRowChanged(object sender, DataRowChangeEventArgs e){
  if (e.Action == Delete)
  {
   Console.WriteLine("deleting row " + e.Row[0].ToString());
  }
}

In the example above, we've created three methods: MyColChanging, MyRowChanging and MyRowChanged. Each of these methods will occur when a column or row changes.