HtmlTable.HtmlTableRowControlCollection Class
Assembly: System.Web (in system.web.dll)
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); } } } }
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI.ControlCollection
System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection
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.