TableRow.TableSection 屬性

定義

取得或設定 TableRow 控制項中 Table 物件的位置。

public:
 virtual property System::Web::UI::WebControls::TableRowSection TableSection { System::Web::UI::WebControls::TableRowSection get(); void set(System::Web::UI::WebControls::TableRowSection value); };
public virtual System.Web.UI.WebControls.TableRowSection TableSection { get; set; }
member this.TableSection : System.Web.UI.WebControls.TableRowSection with get, set
Public Overridable Property TableSection As TableRowSection

屬性值

TableRowSection

TableRowSection 值。 預設為 TableBody

例外狀況

範例

下列程式碼範例示範如何使用 TableSection 屬性來定義 控制項中的 Table 頁首和頁尾資料列。

<%@ page language="C#" %>

<!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 id="Head1" runat="server">
    <title>TableRow, TableFooter Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h1>TableRow, TableFooter Example</h1>
    <asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="0">
        <asp:TableRow TableSection="TableHeader" BackColor="Pink">
            <asp:TableCell Text="Header" ColumnSpan="3" />
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell Text="(0,0)"></asp:TableCell>
            <asp:TableCell Text="(0,1)"></asp:TableCell>
            <asp:TableCell Text="(0,2)"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell Text="(1,0)"></asp:TableCell>
            <asp:TableCell Text="(1,1)"></asp:TableCell>
            <asp:TableCell Text="(1,2)"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow TableSection="TableFooter" BackColor="Pink">
            <asp:TableCell Text="Footer" ColumnSpan="3" />
        </asp:TableRow>
    </asp:table>

    </div>
    </form>
  </body>
</html>
<%@ page language="VB" %>

<!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 id="Head1" runat="server">
    <title>TableRow, TableFooter Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h1>TableRow, TableFooter Example</h1>
    <asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="0">
        <asp:TableRow TableSection="TableHeader" BackColor="Pink">
            <asp:TableCell Text="Header" ColumnSpan="3" />
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell Text="(0,0)"></asp:TableCell>
            <asp:TableCell Text="(0,1)"></asp:TableCell>
            <asp:TableCell Text="(0,2)"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell Text="(1,0)"></asp:TableCell>
            <asp:TableCell Text="(1,1)"></asp:TableCell>
            <asp:TableCell Text="(1,2)"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow TableSection="TableFooter" BackColor="Pink">
            <asp:TableCell Text="Footer" ColumnSpan="3" />
        </asp:TableRow>
    </asp:table>

    </div>
    </form>
  </body>
</html>

備註

TableSection使用 屬性來取得或設定物件放置於 控制項的位置 TableRow Table 。 如需可用的資料表位置,請參閱 TableRowSection 。 下表列出可能的值。

資料表資料列區段 顯示為
TableHeader 標頭資料列。
TableBody 資料表的主體。
TableFooter 頁尾資料列。

使用宣告式語法時,區段的順序必須是頁首、本文,然後是頁尾。

列舉 TableRowSection 可讓您使用 Table 控制項建置可存取的網站,方法是將 、 <tbody><tfoot> 元素新增 <thead> 至轉譯至用戶端的 HTML。 如果資料表中的所有資料列都在 元素中 <tbody> ,則不會轉譯區段資訊。 至少一個資料列必須位於非主體專案中。

這個屬性的值會儲存在檢視狀態中。

適用於

另請參閱