TableRowCollection Class
TOC
Collapse the table of content
Expand the table of content

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)

System.Object
  System.Web.UI.WebControls.TableRowCollection

public sealed class TableRowCollection : IList, ICollection, 
	IEnumerable

NameDescription
System_CAPS_pubpropertyCount

Gets the number of TableRow objects in the TableRowCollection.

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the TableRowCollection is read-only.

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether access to the TableRowCollection is synchronized (thread-safe).

System_CAPS_pubpropertyItem[Int32]

Gets a TableRow from the TableRowCollection at the specified index.

System_CAPS_pubpropertySyncRoot

Gets the object that can be used to synchronize access to the TableRowCollection.

NameDescription
System_CAPS_pubmethodAdd(TableRow)

Appends the specified TableRow object to the end of the TableRowCollection.

System_CAPS_pubmethodAddAt(Int32, TableRow)

Adds the specified TableRow object to the TableRowCollection at the specified index location.

System_CAPS_pubmethodAddRange(TableRow[])

Appends the TableRow objects from the specified array to the end of the collection.

System_CAPS_pubmethodClear()

Removes all TableRow controls from the TableRowCollection.

System_CAPS_pubmethodCopyTo(Array, Int32)

Copies the items from the TableRowCollection to the specified System.Array, starting with the specified index in the System.Array.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns a System.Collections.IEnumerator implemented object that contains all TableRow objects within the TableRowCollection.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetRowIndex(TableRow)

Returns a value that represents the index of the specified TableRow from the TableRowCollection.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodRemove(TableRow)

Removes the specified TableRow from the TableRowCollection.

System_CAPS_pubmethodRemoveAt(Int32)

Removes a TableRow from the TableRowCollection at the specified index.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Add(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Adds an object to the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Contains(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Determines whether the specified object is contained within the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.IndexOf(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Searches for the specified object and returns the zero-based index of the first occurrence within the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Insert(Int32, Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Inserts an object into the collection at the specified index.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Remove(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Removes an object from the collection.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsFixedSize

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IsFixedSize.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.Item[Int32]

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Item.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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.

System_CAPS_noteNote

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.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    void Page_Load(Object sender, EventArgs e)
    {
        // Generate rows and cells.           
        int numRows = 3;
        int numCells = 2;
        for (int rowNum = 0; rowNum < numRows; rowNum++)
        {
            TableRow rw = new TableRow();
            for (int cellNum = 0; cellNum < numCells; cellNum++)
            {
                TableCell cel = new TableCell();
                cel.Text = String.Format(
                    "row {0}, cell {1}", rowNum, cellNum);
                rw.Cells.Add(cel);
            }
            Table1.Rows.Add(rw);
            Table1.GridLines = GridLines.Both;
            Table1.CellPadding = 4;
            Table1.CellSpacing = 0;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Programmatic Table</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Table Example, constructed programmatically</h3>
        <asp:Table id="Table1" runat="server"/>
    </div>
    </form>
</body>
</html>

.NET Framework
Available since 1.1

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

Return to top
Show:
© 2016 Microsoft