System.Web.UI.WebControls Namespace ButtonField Class
.NET Framework version 2.0
Sets or retrieves the text caption to display for the buttons in a ButtonField.
Inline |
<asp:buttonfield text = strText ... > |
Script |
ButtonField.Text = strText |
strText |
String specifying the text caption for the buttons in a ButtonField. |
The property is read/write with no default value.
Use the Text property to specify or determine the text caption to display for each button in a ButtonField control.
NOTE: When this property is set, all buttons in the column share the same text caption.
Alternatively, the ButtonField can be set to display different button captions based on the values of a field in the data source bound to the parent control. To specify using a separate text caption for each button in the column, set the DataTextField property instead.
NOTE: The DataTextField and Text properties cannot both be set at the same time. If both properties are set, the DataTextField property takes precedence.
The following example demonstrates how to use the Text property to specify the text caption for button controls in two ButtonField columns. Notice that all buttons in both columns will render the same text caption.
<columns>
<asp:buttonfield text = "Add"
commandname = "AddToCart" />
<asp:buttonfield text = "Remove"
commandname = "RemoveFromCart" />
...
</columns>
ButtonField Members Adding Button Fields to a GridView Control