asp.net.ph

DataRowCollection.RemoveAt Method

System.Data Namespace   DataRowCollection Class


Removes the row at the given index.

[ VB ]
Public Sub RemoveAt ( _
   ByVal index As Integer _
)

[ C# ]
public void RemoveAt (
   int index
);

[ C++ ]
public: void RemoveAt (
   int index
);

[ JScript ]
public function RemoveAt (
   index : int
);

Parameters

index
The index of the row to remove.

Exceptions


Exception Type Condition
ArgumentException The collection does not have a row at the specified index.

Remarks

Use the RemoveAt method to remove the DataRow object at the specified index in the DataRowCollection.

To remove a specified DataRow object, use the Remove method. You can also use the Clear method to remove all members of the collection at once.

When a row is removed, data in that row is lost. You can also call the DataRow class's Delete method to simply mark a row for removal. The row is not actually removed until the AcceptChanges method is invoked.

Example

The following example removes the last row in a DataRowCollection by calling the RemoveAt method.

private void RemoveRowByIndex ( DataTable myTable ) {
   DataRowCollection myRows = myTable.Rows;
   if ( myRows.Count == 0 ) return;
   myRows.RemoveAt ( myRows.Count - 1 );
}
  C# VB

See Also

DataRowCollection Members   Clear   Add Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph