TableRowCollection Class

Encapsulates a collection of TableRow objects that represent a single row in a Table control. This class cannot be inherited.

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

public ref class TableRowCollection sealed : IList, ICollection, IEnumerable
public final class TableRowCollection implements IList, ICollection, 
public final class TableRowCollection implements IList, ICollection, 
Not applicable.

Use this class to programmatically manage a collection of TableRow objects. This class is commonly used to add or remove rows from a Table control.


A Table control contains a Rows collection that represents a collection of TableRow objects. Each TableRow represents an individual row in the table and contains a Cells collection that represents a collection of TableCell objects. These TableCell objects represent the individual cells in the table. To get an individual cell, you must first get a TableRow from the Rows collection of a Table control. You can then get a TableCell from the Cells collection of the TableRow.

The following example demonstrates how to programmatically add rows to a table by adding TableRow objects, which represent the rows of the table, to the Table control through the Rows property.

No code example is currently available or this language may not be supported.

    <script language="C#" runat="server">
        void Page_Load(Object sender, EventArgs e) {
            // Generate rows and cells           
            int numrows = 3;
            int numcells = 2;
            for (int j=0; j<numrows; j++) {          
                TableRow r = new TableRow();
                for (int i=0; i<numcells; i++) {
                    TableCell c = new TableCell();
                    c.Text="row " + j.ToString() + ", cell " + i.ToString();
    <h3><font face="Verdana">Table Example, constructed programmatically</font></h3>
    <form runat=server>
        <asp:Table id="Table1"

  • AspNetHostingPermission  For operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0