Table.CreateControlCollection Method
Assembly: System.Web (in system.web.dll)
This method is used primarily by control developers when deriving a custom class from a Table control.
This method overrides the CreateControlCollection implementation for the base Control class. For a Table control, the CreateControlCollection always returns a ControlCollection that can only contain TableRow controls of the current Table control.
The following code example demonstrates how to override the CreateControlCollection method in a custom server control so that it always returns a new instance of the EmptyControlCollection class for the Table.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Table - CreateControlCollection - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Table - CreateControlCollection - VJ# Example</h3>
<aspSample:CustomTableCreateControlCollection
id="Table1"
runat="server"
GridLines="Both"
CellPadding="4">
<asp:TableRow>
<asp:TableCell>Row 0, Col 0</asp:TableCell>
<asp:TableCell>Row 0, Col 1</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>Row 1, Col 0</asp:TableCell>
<asp:TableCell>Row 1, Col 1</asp:TableCell>
</asp:TableRow>
</aspSample:CustomTableCreateControlCollection>
</form>
</body>
</HTML>
...package Samples.AspNet.JSL.Controls;
public class CustomTableCreateControlCollection
extends System.Web.UI.WebControls.Table
{
protected System.Web.UI.ControlCollection CreateControlCollection()
{
// Return a new EmptyControlCollection
return new System.Web.UI.EmptyControlCollection(this);
} //CreateControlCollection
} //CustomTableCreateControlCollection
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.