ButtonField.Text プロパティ
アセンブリ: System.Web (system.web.dll 内)

[LocalizableAttribute(true)] public: virtual property String^ Text { String^ get (); void set (String^ value); }
ButtonField の各ボタンに表示されるキャプション。既定値は空の文字列 ("") です。

ButtonField オブジェクトの ButtonType プロパティに Button またはLink 値を設定すると、Text プロパティを使用して、ButtonField のボタンのキャプションに静的テキストを表示できます。各ボタンは同じキャプションを共有します。
Text プロパティを使用して ButtonField オブジェクトに静的テキストを表示する代わりに、DataTextField プロパティを使用して ButtonField をデータ ソースのフィールドにバインドできます。この場合、フィールドの値がボタンのキャプションとして表示されます。
![]() |
---|
DataTextField プロパティと Text プロパティの両方が設定されている場合は、DataTextField プロパティが優先されます。 |
このプロパティの値は、設定時に、デザイナ ツールを使用してリソース ファイルに自動的に保存できます。詳細については、LocalizableAttribute、ASP.NET のグローバリゼーションおよびローカリゼーション の各トピックを参照してください。

Text プロパティを使用して、ButtonField オブジェクトの各ボタンに表示するキャプションを指定する方法を次のコード例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub CustomersGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) ' If multiple ButtonField column fields are used, use the ' CommandName property to determine which button was clicked. If e.CommandName = "Select" Then ' Convert the row index stored in the CommandArgument ' property to an Integer. Dim index As Integer = Convert.ToInt32(e.CommandArgument) ' Get the last name of the selected author from the appropriate ' cell in the GridView control. Dim selectedRow As GridViewRow = CustomersGridView.Rows(index) Dim contactCell As TableCell = selectedRow.Cells(1) Dim contact As String = contactCell.Text ' Display the selected author. Message.Text = "You selected " & contact & "." End If End Sub </script> <html> <body> <form id="Form1" runat="server"> <h3>ButtonField Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <!-- Populate the Columns collection declaratively. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" onrowcommand="CustomersGridView_RowCommand" runat="server"> <columns> <asp:buttonfield buttontype="Button" commandname="Select" headertext="Select Customer" text="Select"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="ContactName" headertext="Contact Name"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [ContactName], [ContactTitle] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void CustomersGridView_RowCommand(Object sender, GridViewCommandEventArgs e) { // If multiple ButtonField column fields are used, use the // CommandName property to determine which button was clicked. if(e.CommandName=="Select") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32(e.CommandArgument); // Get the last name of the selected author from the appropriate // cell in the GridView control. GridViewRow selectedRow = CustomersGridView.Rows[index]; TableCell contactName = selectedRow.Cells[1]; string contact = contactName.Text; // Display the selected author. Message.Text = "You selected " + contact + "."; } } </script> <html> <body> <form runat="server"> <h3>ButtonField Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <!-- Populate the Columns collection declaratively. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" onrowcommand="CustomersGridView_RowCommand" runat="server"> <columns> <asp:buttonfield buttontype="Button" commandname="Select" headertext="Select Customer" text="Select"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="ContactName" headertext="Contact Name"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [ContactName], [ContactTitle] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" runat="server"> </asp:sqldatasource> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からButtonField.Text プロパティを検索する場合は、下記のリンクをクリックしてください。

- ButtonField.Text プロパティのページへのリンク