System.Data Namespace DataView Class
Occurs when the list managed by the DataView changes.
[ VB ]
Overridable Public Event ListChanged As ListChangedEventHandler
[ C# ]
public virtual event ListChangedEventHandler ListChanged;
[ C++ ]
public: virtual __event ListChangedEventHandler* ListChanged;
In [ JScript ], you can handle the events defined by a class, but you cannot define your own.
The event handler receives a ListChangedEventArgs containing data related to the ListChanged event. The following ListChangedEventArgs properties provide information specific to this event.
Property |
Description |
ListChangedType |
Gets the way that the list changed. |
NewIndex |
Gets the new index of the item in the list. |
OldIndex |
Gets the old index of the item in the list. |
For more information about handling events, see Web Forms Events and Handlers.
The following example illustrates how to programmatically add a handler for the ListChanged event of a DataView.
void CreateDataView ( DataTable dt ) {
DataView dv = new DataView ( dt, "", "ContactName", DataViewRowState.CurrentRows );
dv.ListChanged += new System.ComponentModel.ListChangedEventHandler
( OnListChanged );
}
protected void OnListChanged ( object src,
System.ComponentModel.ListChangedEventArgs args ) {
Response.Write ( "ListChanged:" );
Response.Write ( "\t Type = " + args.ListChangedType );
Response.Write ( "\tOldIndex = " + args.OldIndex );
Response.Write ( "\tNewIndex = " + args.NewIndex );
}
Public Sub CreateDataView ( dt As DataTable )
Dim dv As DataView = New DataView ( dt, "", "ContactName", DataViewRowState.CurrentRows )
AddHandler dv.ListChanged, New System.ComponentModel.ListChangedEventHandler _
( AddressOf OnListChanged )
End Sub
Protected Sub OnListChanged ( src as Object, _
args As System.ComponentModel.ListChangedEventArgs )
Response.Write ( "ListChanged:" )
Response.Write ( "<br>" & " Type = " & args.ListChangedType )
Response.Write ( "<br>" & "OldIndex = " & args.OldIndex )
Response.Write ( "<br>" & "NewIndex = " & args.NewIndex )
End Sub |
|
C# |
VB |
DataView Members