HtmlTableRow Server Control Declarative Syntax 

Creates a server-side control that maps to the <tr> HTML element and allows you to create and manipulate a row in a table.

    OnDataBinding="OnDataBinding event handler"
    OnDisposed="OnDisposed event handler"
    OnInit="OnInit event handler"
    OnLoad="OnLoad event handler"
    OnPreRender="OnPreRender event handler"
    OnUnload="OnUnload event handler"

Use the HtmlTableRow class to program against the <tr> HTML element. A <tr> element represents a row in the table.

The HtmlTableRow class allows you to control the appearance of each individual row in the table. You can control the background color, border color, and height of the row by setting the BgColor, BorderColor, and Height properties, respectively.

The horizontal and vertical alignment of the contents of the cells in the row are controlled by setting the Align and VAlign properties, respectively.

Each row in the table contains a Cells collection, which contains an HtmlTableCell for each cell in the row.

The following example demonstrates how use an HtmlTableCell to modify the contents of a cell in the HtmlTable control.

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

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

<html xmlns="" >

<title>HtmlTableRow Control</title>

   <script runat="server">
      void Button_Click(Object sender, EventArgs e) 

         // Iterate through the rows of the table.
         for (int i=0; i<=Table1.Rows.Count - 1; i++)

            // Iterate through the cells of a row.
            for (int j=0; j<=Table1.Rows[i].Cells.Count - 1; j++)
               // Change the inner HTML of the cell.
               Table1.Rows[i].Cells[j].InnerHtml = "Row " + i.ToString() + 
                                                   ", Column " + 




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

      <h3>HtmlTableCell Example</h3>

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

               Cell 1
               Cell 2
               Cell 3
               Cell 4


      <br /><br />
      <input id="Button1" type="button" 
             value="Change Table Contents"


Community Additions