TableRowCollection.RemoveAt Method (Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Removes a TableRow from the TableRowCollection at the specified index.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public void RemoveAt(
	int index


Type: System.Int32

The index of the TableRow object to remove from the TableRowCollection.

Use this method to remove a TableRow from the TableRowCollection at the specified index.

The following example demonstrates how to use the RemoveAt method to remove a row from the table. Note that in the example, the Rows property of the Table is an instance of the TableRowCollection class. Also note that the index of the Rows collection is zero-based.

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Text" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim numRows As Integer = 5
        Dim numCells As Integer = 6
        Dim counter As Integer = 1
        Dim a_row As New ArrayList()

        ' Create a table.
        Dim rowNum As Integer
        For rowNum = 0 To numRows - 1
            Dim rw As New TableRow()
            Dim cellNum As Integer
            For cellNum = 0 To numCells - 1
                Dim cel As New TableCell()
                cel.Text = counter.ToString()
                counter += 1
    End Sub

    Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
    End Sub

<html xmlns="" >
<head id="Head2" runat="server">
    <title>TableCellCollection Example</title>
    <form id="form1" runat="server">
        <h3>TableCellCollection Example</h3>
        <asp:Table id="Table1" runat="server"/>
        <br />&nbsp;<br />
        <asp:Button id="Button1"
            Text="Remove middle row"

.NET Framework
Available since 1.1
Return to top