HtmlTable.HtmlTableRowControlCollection 类

定义

表示作为 HtmlTableRow 控件的行的 HtmlTable 对象的集合。Represents a collection of HtmlTableRow objects that are the rows of an HtmlTable control.

protected: ref class HtmlTable::HtmlTableRowControlCollection : System::Web::UI::ControlCollection
protected class HtmlTable.HtmlTableRowControlCollection : System.Web.UI.ControlCollection
Protected Class HtmlTable.HtmlTableRowControlCollection
Inherits ControlCollection
继承
HtmlTable.HtmlTableRowControlCollection

示例

下面的代码示例演示如何创建一个HtmlTable.HtmlTableRowControlCollection Add重写方法的自定义, 以便在将行添加到表时, 这些行始终添加到表的行集合的开头。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> 
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" 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);
         }
       }
    }
}
Imports System.Web
Imports System.Web.UI
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomHtmlTableRowControlCollection
        Inherits System.Web.UI.HtmlControls.HtmlTable

        Protected Overrides Function CreateControlCollection() As System.Web.UI.ControlCollection

            Return New MyHtmlTableRowControlCollection(Me)

        End Function

        Protected Class MyHtmlTableRowControlCollection
            Inherits ControlCollection

            Friend Sub New(ByVal owner As Control)

                MyBase.New(owner)

            End Sub

            Public Overrides Sub Add(ByVal child As Control)

                ' Always add new rows at the top of the table.
                MyBase.AddAt(0, child)

            End Sub

        End Class

    End Class

End Namespace

注解

类表示HtmlTable控件的HtmlTableRow对象的集合。 HtmlTable.HtmlTableRowControlCollectionThe HtmlTable.HtmlTableRowControlCollection class represents a collection of HtmlTableRow objects for an HtmlTable control. 可以使用Add方法在集合的末尾添加控件, 也可以AddAt使用方法在集合中的指定索引位置添加控件。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. 只能将类型HtmlTableRow的控件添加HtmlTable.HtmlTableRowControlCollection到集合中。Only controls of type HtmlTableRow can be added to the HtmlTable.HtmlTableRowControlCollection collection.

属性

Count

为指定的 ASP.NET 服务器控件获取 ControlCollection 对象中的服务器控件数。Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control.

(继承自 ControlCollection)
IsReadOnly

获取一个值,该值指示 ControlCollection 对象是否为只读。Gets a value indicating whether the ControlCollection object is read-only.

(继承自 ControlCollection)
IsSynchronized

获取一个值,该值指示 ControlCollection 对象是否已同步。Gets a value indicating whether the ControlCollection object is synchronized.

(继承自 ControlCollection)
Item[Int32]

获取对 ControlCollection 对象中指定索引位置的服务器控件的引用。Gets a reference to the server control at the specified index location in the ControlCollection object.

(继承自 ControlCollection)
Owner

获取 ControlCollection 对象所属的 ASP.NET 服务器控件。Gets the ASP.NET server control to which the ControlCollection object belongs.

(继承自 ControlCollection)
SyncRoot

获取可用于同步控件集合访问的对象。Gets an object that can be used to synchronize access to the collection of controls.

(继承自 ControlCollection)

方法

Add(Control)

将指定的 Control 对象添加到集合。Adds the specified Control object to the collection.

AddAt(Int32, Control)

将指定的 Control 对象添加到集合。Adds the specified Control object to the collection. 将新控件添加到数组的指定索引位置。The new control is added to the array at the specified index location.

Clear()

从当前服务器控件的 ControlCollection 对象中移除所有控件。Removes all controls from the current server control's ControlCollection object.

(继承自 ControlCollection)
Contains(Control)

确定指定的服务器控件是否在父服务器控件的 ControlCollection 对象中。Determines whether the specified server control is in the parent server control's ControlCollection object.

(继承自 ControlCollection)
CopyTo(Array, Int32)

ControlCollection 中的指定索引位置开始,将 Array 对象中存储的子控件复制到 Array 对象。Copies the child controls stored in the ControlCollection object to an Array object, beginning at the specified index location in the Array.

(继承自 ControlCollection)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

检索可以循环访问 ControlCollection 对象的枚举数。Retrieves an enumerator that can iterate through the ControlCollection object.

(继承自 ControlCollection)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IndexOf(Control)

检索集合中指定 Control 对象的索引。Retrieves the index of a specified Control object in the collection.

(继承自 ControlCollection)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Remove(Control)

从父服务器控件的 ControlCollection 对象中移除指定服务器控件。Removes the specified server control from the parent server control's ControlCollection object.

(继承自 ControlCollection)
RemoveAt(Int32)

ControlCollection 对象中移除指定索引位置处的子控件。Removes a child control, at the specified index location, from the ControlCollection object.

(继承自 ControlCollection)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅