HtmlTable.HtmlTableRowControlCollection Class
.NET Framework 3.0
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)
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" %> <!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); } } } }
- 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.Object
System.Web.UI.ControlCollection
System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection
System.Web.UI.ControlCollection
System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection
Community Additions
ADD
Show: