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=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] 
public:
virtual property String^ DataTextField {
	String^ get ();
	void set (String^ value);
}
/** @property */
public String get_DataTextField ()

/** @property */
public void set_DataTextField (String value)

public function get DataTextField () : String

public function set DataTextField (value : String)

Not applicable.

Property Value

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.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: