共用方式為


TableHeaderCell.Scope 屬性

定義

取得或設定 TableHeaderCell 控制項在呈現時的範圍。

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

屬性值

TableHeaderScope 值。 預設為 NotSet

範例

下列程式碼範例示範如何以宣告方式撰寫 Scope 屬性。 請注意 屬性的使用 AssociatedHeaderCellID

<%@ 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>TableHeaderCell Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h1>TableHeaderCell Example</h1>
    <asp:table id="Table1" runat="server" 
        CellPadding="3" 
        CellSpacing="3" 
        BorderWidth="1" 
        GridLines="Both"> 
        <asp:TableHeaderRow ID="TableHeaderRow1" runat="server">
            <asp:TableHeaderCell runat="server" 
                ID="Column1Header"
                CategoryText="Column1"
                AbbreviatedText="Header 1"
                Scope="Column" 
                HorizontalAlign="Center" 
                VerticalAlign="Middle" 
                BackColor="LightGray">
                Column 1 Header
            </asp:TableHeaderCell>
            <asp:TableHeaderCell runat="server"
                ID="Column2Header"
                CategoryText="Column2,Column2Alternative"
                AbbreviatedText="Header 2"
                Scope="Column"
                HorizontalAlign="Center" 
                VerticalAlign="Middle"
                BackColor="LightGray">
                Column 2 Header
            </asp:TableHeaderCell>                                        
            <asp:TableHeaderCell runat="server" 
                ID="Column3Header"
                CategoryText="Column3"
                AbbreviatedText="Header 3"
                Scope="Column"
                HorizontalAlign="Center" 
                VerticalAlign="Middle"
                BackColor="LightGray">
                Column 3 Header
            </asp:TableHeaderCell>                                        
        </asp:TableHeaderRow>
        <asp:TableRow HorizontalAlign="Center">
            <asp:TableCell AssociatedHeaderCellID="Column1Header"
                HorizontalAlign="Left">
                (0,0)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column2Header">
                (0,1)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column3Header">
                (0,2)
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow 
            HorizontalAlign="Center">
            <asp:TableCell 
                AssociatedHeaderCellID="Column1Header"
                HorizontalAlign="Left">
                (1,0)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column2Header">
                (1,1)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column3Header">
                (1,2)
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow 
            HorizontalAlign="Center">
            <asp:TableCell 
                AssociatedHeaderCellID=
                    "Column1Header,Column2Header,Column3Header"
                ColumnSpan="3"
                HorizontalAlign="Left">
                (2,0)
            </asp:TableCell>
        </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>TableHeaderCell Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h1>TableHeaderCell Example</h1>
    <asp:table id="Table1" runat="server" 
        CellPadding="3" 
        CellSpacing="3" 
        BorderWidth="1" 
        GridLines="Both"> 
        <asp:TableHeaderRow ID="TableHeaderRow1" runat="server">
            <asp:TableHeaderCell runat="server" 
                ID="Column1Header"
                CategoryText="Column1"
                AbbreviatedText="Header 1"
                Scope="Column" 
                HorizontalAlign="Center" 
                VerticalAlign="Middle" 
                BackColor="LightGray">
                Column 1 Header
            </asp:TableHeaderCell>
            <asp:TableHeaderCell runat="server"
                ID="Column2Header"
                CategoryText="Column2,Column2Alternative"
                AbbreviatedText="Header 2"
                Scope="Column"
                HorizontalAlign="Center" 
                VerticalAlign="Middle"
                BackColor="LightGray">
                Column 2 Header
            </asp:TableHeaderCell>                                        
            <asp:TableHeaderCell runat="server" 
                ID="Column3Header"
                CategoryText="Column3"
                AbbreviatedText="Header 3"
                Scope="Column"
                HorizontalAlign="Center" 
                VerticalAlign="Middle"
                BackColor="LightGray">
                Column 3 Header
            </asp:TableHeaderCell>                                        
        </asp:TableHeaderRow>
        <asp:TableRow HorizontalAlign="Center">
            <asp:TableCell AssociatedHeaderCellID="Column1Header"
                HorizontalAlign="Left">
                (0,0)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column2Header">
                (0,1)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column3Header">
                (0,2)
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow 
            HorizontalAlign="Center">
            <asp:TableCell 
                AssociatedHeaderCellID="Column1Header"
                HorizontalAlign="Left">
                (1,0)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column2Header">
                (1,1)
            </asp:TableCell>
            <asp:TableCell 
                AssociatedHeaderCellID="Column3Header">
                (1,2)
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow 
            HorizontalAlign="Center">
            <asp:TableCell 
                AssociatedHeaderCellID=
                    "Column1Header,Column2Header,Column3Header"
                ColumnSpan="3"
                HorizontalAlign="Left">
                (2,0)
            </asp:TableCell>
        </asp:TableRow>
    </asp:table>

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

備註

Scope使用 屬性,在呈現控制項時取得或設定控制項的範圍 TableHeaderCell 。 的範圍 TableHeaderCell 代表標頭所套用的儲存格。 對於複雜的資料表,請使用 AssociatedHeaderCellID 屬性,以更充分控制標頭儲存格與資料格關聯性的規格。 屬性 Scope 可用來提供儲存格與標頭之間關聯性的相關資訊,讓 HTML 資料表更容易存取。

如需可用資料表標頭範圍的清單,請參閱 TableHeaderScope

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

適用於

另請參閱