Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

HtmlTable.HtmlTableRowControlCollection Class

Represents a collection of HtmlTableRow objects that are the rows of an HtmlTable control.

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

protected class HtmlTableRowControlCollection : ControlCollection
protected class HtmlTableRowControlCollection extends ControlCollection
protected class HtmlTableRowControlCollection extends ControlCollection

The HtmlTable.HtmlTableRowControlCollection class represents a collection of HtmlTableRow objects for an HtmlTable control. Controls can be added at the end of the collection with the Add method, or at a specified index location in the collection with the AddAt method. Only controls of type HtmlTableRow can be added to the HtmlTable.HtmlTableRowControlCollection collection.

The following code example demonstrates how to create a custom HtmlTable.HtmlTableRowControlCollection that overrides the Add method so that when rows are added to a table, they are always added at the beginning of the table's row collection.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
  <head>
    <title>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</title>
  </head>
  <body>
    <form id="Form1" 
          method="post" 
          runat="server">
      <h3>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</h3>
      
      <aspSample:CustomHtmlTableRowControlCollection 
        id="HtmlTable1" 
        name="HtmlTable1" 
        runat="server" 
        border="1"
        cellSpacing="0" 
        cellPadding="5">
        <TR>
          <TD>1,1</TD>
          <TD>1,2</TD>
          <TD>1,3</TD>
        </TR>
        <TR>
          <TD>2,1</TD>
          <TD>2,2</TD>
          <TD>2,3</TD>
        </TR>
        <TR>
          <TD>3,1</TD>
          <TD>3,2</TD>
          <TD>3,3</TD>
        </TR>
      </aspSample:CustomHtmlTableRowControlCollection>

    </form>

  </body>
</html> 

using System.Web;
using System.Web.UI;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class CustomHtmlTableRowControlCollection : System.Web.UI.HtmlControls.HtmlTable
    {

       protected override ControlCollection CreateControlCollection()
       {

         return new MyHtmlTableRowControlCollection(this);

       }

       protected class MyHtmlTableRowControlCollection : ControlCollection
       {

         internal MyHtmlTableRowControlCollection(Control owner) : base(owner) { }

         public override void Add(Control child)
         {

           // Always add new rows at the top of the table.
           base.AddAt(0, child);
         }

       }

    }

}

System.Object
   System.Web.UI.ControlCollection
    System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection
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 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.