ButtonField::DataTextField Property
Gets or sets the name of the data field for which the value is bound to the Text property of the Button control that is rendered by the ButtonField object.
Assembly: System.Web (in System.Web.dll)
public: [TypeConverterAttribute("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] property String^ DataTextField { virtual String^ get(); virtual void set(String^ value); }
Property Value
Type: System::String^The name of the field to bind to the ButtonField. The default is an empty string (""), which indicates that the DataTextField property is not set.
When the ButtonType property of a ButtonField object is set to the Button or Link value, use the DataTextField property to specify the name of the field to bind to the ButtonField object. The values of the field are then displayed as the text for the buttons in the ButtonField object. Optionally, you can format the displayed text by setting the DataTextFormatString property.
Instead of using the DataTextField property to bind a ButtonField object to a field from a data source, you can use the Text property to display static text for the text of the buttons in the ButtonField object. When the Text property is used, each button shares the same caption.
Note |
|---|
If the DataTextField and Text properties are both set, the DataTextField property takes precedence. |
The value of this property is stored in view state.
The following code example demonstrates how to use the DataTextField property to specify which field to display in a ButtonField column of a GridView control.
Available since 2.0
