HtmlTableRow.Cells Property


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

Gets a collection of HtmlTableCell objects that represent the cells contained in a row of the HtmlTable control.

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

Public Overridable ReadOnly Property Cells As HtmlTableCellCollection

Property Value

Type: System.Web.UI.HtmlControls.HtmlTableCellCollection

An HtmlTableCellCollection that contains the cells of a row in an HtmlTable control.

Use the Cells collection to programmatically access the cells of a row in an HtmlTable control. You can programmatically add, remove, and insert cells in the collection.


If there are no cells defined in a row, an empty HtmlTableCellCollection object is returned.

The following code example demonstrates how to use the Cells collection to iterate through the cells of a row, represented by an HtmlTableRow object. The cells are then updated with new content.

<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

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

    Dim i As Integer
    Dim j As Integer

    ' Iterate through the rows of the table.
    For i = 0 To Table1.Rows.Count - 1

      ' Iterate through the cells of a row.       
      For j = 0 To Table1.Rows(i).Cells.Count - 1

        ' Change the inner HTML of the cell.
        Table1.Rows(i).Cells(j).InnerHtml = "Row " & i.ToString() & _
                                            ", Column " & j.ToString()
      Next j

    Next i

  End Sub


<html xmlns="" >
   <title>HtmlTableRow Example</title>

   <form id="form1" runat="server">

      <h3>HtmlTableRow Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black"

               Cell 1
               Cell 2
               Cell 3
               Cell 4


      <br /><br />

      <input type="button" 
             value="Change Table Contents"



.NET Framework
Available since 1.1
Return to top