CheckBoxField.Text 屬性

定義

取得或設定要在 CheckBoxField 物件中每個核取方塊旁邊顯示的標題。

public:
 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public virtual string Text { get; set; }
member this.Text : string with get, set
Public Overridable Property Text As String

屬性值

CheckBoxField 中每個核取方塊旁邊顯示的標題。 預設為空字串 ("")。

範例

下列程式碼範例示範如何使用 Text 屬性來指定 控制項物件中 CheckBoxField 核取方塊的 GridView 自訂標題。


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

      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="au_lname"
            headertext="Last Name"/>
                    
          <asp:checkboxfield datafield="contract"
            text="Contract"
            headertext="Contract"/>     
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_lname], [au_fname], [address], [city], [state], [zip], [contract] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </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 runat="server">
    <title>CheckBoxField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>CheckBoxField Example</h3>

      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="au_lname"
            headertext="Last Name"/>
                    
          <asp:checkboxfield datafield="contract"
            text="Contract"
            headertext="Contract"/>     
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_lname], [au_fname], [address], [city], [state], [zip], [contract] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

備註

屬性 Text 用來顯示 物件中每個核取方塊旁的 CheckBoxField 標題。 Text如果屬性設定為空字串,則不會顯示任何標題。

注意

物件中的所有 CheckBoxField 核取方塊都會共用相同的標題。

設定時,這個屬性的值可以使用設計工具自動儲存到資源檔。 如需詳細資訊,請參閱 LocalizableAttribute全球化和當地語系化

適用於

另請參閱