HtmlTableRow.Cells Property
.NET Framework (current version)
Gets a collection of HtmlTableCell objects that represent the cells contained in a row of the HtmlTable control.
Assembly: System.Web (in System.Web.dll)
<BrowsableAttribute(False)> Public Overridable ReadOnly Property Cells As HtmlTableCellCollection
Property Value
Type: System.Web.UI.HtmlControls.HtmlTableCellCollectionAn 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.
Note |
|---|
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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 </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>HtmlTableRow Example</title> </head> <body> <form id="form1" runat="server"> <h3>HtmlTableRow Example</h3> <table id="Table1" style="border-width:1; border-color:Black" runat="server"> <tr> <td> Cell 1 </td> <td> Cell 2 </td> </tr> <tr> <td> Cell 3 </td> <td> Cell 4 </td> </tr> </table> <br /><br /> <input type="button" value="Change Table Contents" onserverclick="Button_Click" runat="server"/> </form> </body> </html>
.NET Framework
Available since 1.1
Available since 1.1
Show:
