Export (0) Print
Expand All

HtmlTable.HtmlTableRowControlCollection Class

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

System.Object
  System.Web.UI.ControlCollection
    System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection

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

protected class HtmlTableRowControlCollection : ControlCollection

The HtmlTable.HtmlTableRowControlCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of server controls in the ControlCollection object for the specified ASP.NET server control. (Inherited from ControlCollection.)
Public propertyIsReadOnlyGets a value indicating whether the ControlCollection object is read-only. (Inherited from ControlCollection.)
Public propertyIsSynchronizedGets a value indicating whether the ControlCollection object is synchronized. (Inherited from ControlCollection.)
Public propertyItemGets a reference to the server control at the specified index location in the ControlCollection object. (Inherited from ControlCollection.)
Protected propertyOwnerGets the ASP.NET server control to which the ControlCollection object belongs. (Inherited from ControlCollection.)
Public propertySyncRootGets an object that can be used to synchronize access to the collection of controls. (Inherited from ControlCollection.)
Top

  NameDescription
Public methodAddAdds the specified Control object to the collection. (Overrides ControlCollection.Add(Control).)
Public methodAddAtAdds the specified Control object to the collection. The new control is added to the array at the specified index location. (Overrides ControlCollection.AddAt(Int32, Control).)
Public methodClearRemoves all controls from the current server control's ControlCollection object. (Inherited from ControlCollection.)
Public methodContainsDetermines whether the specified server control is in the parent server control's ControlCollection object. (Inherited from ControlCollection.)
Public methodCopyToCopies the child controls stored in the ControlCollection object to an System.Array object, beginning at the specified index location in the System.Array. (Inherited from ControlCollection.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorRetrieves an enumerator that can iterate through the ControlCollection object. (Inherited from ControlCollection.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfRetrieves the index of a specified Control object in the collection. (Inherited from ControlCollection.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the specified server control from the parent server control's ControlCollection object. (Inherited from ControlCollection.)
Public methodRemoveAtRemoves a child control, at the specified index location, from the ControlCollection object. (Inherited from ControlCollection.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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);
         }

       }

    }

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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