System.Data Namespace DataView Class
Deletes a row at the specified index.
[ VB ]
Public Sub Delete ( _
ByVal index As Integer _
)
[ C# ]
void Delete (
int index
);
[ C++ ]
public: void Delete (
int index
);
[ JScript ]
public function Delete (
index : int
);
- index
- The index of the row to delete.
After deleting a DataRow, its state changes to DataViewRowState.Deleted. You can roll back the deletion by calling RejectChanges on the DataTable.
The following example uses the Delete method to delete a row.
private void DeleteRow ( DataView dv, String val ) {
// Find the given value in the DataView and delete the row.
int i = dv.Find ( val );
if ( i > -1 )
dv.Delete ( i );
else {
// the value wasn't found
Response.Write ( "Value not found in primary key column" );
}
}
Private Sub DeleteRow ( dv As DataView, val As String )
' Find the given value in the DataView and delete the row.
Dim i As Integer = dv.Find ( val )
If i > -1 Then
dv.Delete ( i )
Else
' the value wasn't found
Response.Write ( "Value not found in primary key column" )
End If
End Sub |
|
C# |
VB |
DataView Members DataViewRowState Find