TableCellCollection.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 TableCell from the TableCellCollection 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 TableCell to remove from the TableCellCollection.

Use this method to remove a TableCell from a TableCellCollection at the specified index.

The following example demonstrates how use the RemoveAt method to remove the fourth column from the table. Note that in the example, the Cells property of the TableRow is an instance of the TableCellCollection class. Also note that the index of the Cells collection is zero-based.

<%@ Page Language="C#" %>

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

<script runat="server">

    void Page_Load(Object sender, EventArgs e)
        int numRows = 5;
        int numCells = 7;
        int counter = 1;

        // Create a table.
        for (int rowNum = 0; rowNum < numRows; rowNum++)
            TableRow rw = new TableRow();
            for (int cellNum = 0; cellNum < numCells; cellNum++)
                TableCell cel = new TableCell();
                cel.Text = counter.ToString();

        // Remove the center column.
        for (int rowNum = 0; rowNum < numRows; rowNum++)


<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" />


.NET Framework
Available since 1.1
Return to top