This documentation is archived and is not being maintained.

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.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[TypeConverterAttribute(L"System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public:
virtual property String^ DataTextField {
	String^ get ();
	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.

NoteNote

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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: