Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

TableRowCollection.Remove Method

Removes the specified TableRow from the TableRowCollection.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
public void Remove(
	TableRow row


Type: System.Web.UI.WebControls.TableRow

The TableRow object to remove from the TableRowCollection.

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

The following example demonstrates how to use the Remove 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.

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

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

<script runat="server">
    void Page_Load(Object sender, EventArgs e)
        // Generate rows and cells.           
        int numRows = 5;
        int numCells = 6;
    int counter = 1;

        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();
            Table1.GridLines = GridLines.Both;
            Table1.CellPadding = 4;
            Table1.CellSpacing = 0;

    void Button_Click(object sender, EventArgs e)
        TableRow rw = Table1.Rows[2];

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" 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

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft. All rights reserved.