HtmlTable.HtmlTableRowControlCollection 类

定义

表示作为 HtmlTableRow 控件的行的 HtmlTable 对象的集合。

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

示例

下面的代码示例演示如何创建替代 方法的Add自定义HtmlTable.HtmlTableRowControlCollection,以便在将行添加到表中时,它们始终添加到表的行集合的开头。

<%@ 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.HtmlTableRowControlCollection 表示控件的 HtmlTableRow 对象的 HtmlTable 集合。 可以使用 方法在集合 Add 末尾添加控件,或使用 方法在集合 AddAt 中的指定索引位置添加控件。 只能将 类型的 HtmlTableRow 控件添加到集合中 HtmlTable.HtmlTableRowControlCollection

属性

Count

为指定的 ASP.NET 服务器控件获取 ControlCollection 对象中的服务器控件数。

(继承自 ControlCollection)
IsReadOnly

获取一个值,该值指示 ControlCollection 对象是否为只读。

(继承自 ControlCollection)
IsSynchronized

获取一个值,该值指示是否同步 ControlCollection 对象。

(继承自 ControlCollection)
Item[Int32]

获取对 ControlCollection 对象中指定索引位置的服务器控件的引用。

(继承自 ControlCollection)
Owner

获取 ControlCollection 对象所属的 ASP.NET 服务器控件。

(继承自 ControlCollection)
SyncRoot

获取可用于同步控件集合访问的对象。

(继承自 ControlCollection)

方法

Add(Control)

将指定的 Control 对象添加到集合。

AddAt(Int32, Control)

将指定的 Control 对象添加到集合。 将新控件添加到数组的指定索引位置。

Clear()

从当前服务器控件的 ControlCollection 对象中移除所有控件。

(继承自 ControlCollection)
Contains(Control)

确定指定的服务器控件是否在父服务器控件的 ControlCollection 对象中。

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

ControlCollection 中的指定索引位置开始,将 Array 对象中存储的子控件复制到 Array 对象。

(继承自 ControlCollection)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

检索可遍历 ControlCollection 对象的枚举器。

(继承自 ControlCollection)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(Control)

检索集合中指定 Control 对象的索引。

(继承自 ControlCollection)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Remove(Control)

从父服务器控件的 ControlCollection 对象中移除指定服务器控件。

(继承自 ControlCollection)
RemoveAt(Int32)

ControlCollection 对象中移除指定索引位置处的子控件。

(继承自 ControlCollection)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于

另请参阅